Once you have retrieved the report and the parameter you wish to modify, you may modify the parameter in one of two ways:
If the parameter already has a current value, you may change it directly. Note that parameter values are changed differently depending on whether or not they are ranged or discrete. To determine whether a parameter is ranged or discrete, use IsRangeValue Property and IsSingleValue Property respectively. You should also check the parameter value's type using the ValueType Property.
Set Result = InfoStore.Query("Select Top 1* From CI_INFOOBJECTS Where" & _
"SI_PROGID = 'CrystalEnterprise.Report'")
Set ReportObject = Result.Item(1).PluginInterface
With ReportObject.ReportParameters.Item(1).CurrentValues.Item(1)
'Check if a string value is being used.
If .ValueType = 6 Then .Value = "Some String"
'Check if a string value is being used.
This example deletes all of the parameter's current values and adds new ones.
Set Result = InfoStore.Query("Select Top 1* From CI_INFOOBJECTS Where" & _
"SI_PROGID = 'CrystalEnterprise.Report'")
Set ReportObject = Result.Item(1).PluginInterface
Ser CurrentValues = ReportObject.ReportParameters.CurrentValues;
Set NewSingleParam = ReportObject.ReportParameters.CreateSingleValue
ReportObject.ReportParameters.Item(1).CurrentValues.Add NewSingleParam
Set NewRangeParam = ReportObject.ReportParameters.CreateRangeValue
ReportObject.ReportParameters.Item(1).CurrentValues.Add NewRangeParam
Once the report parameters have been modified, you may schedule the report in the usual manner. For more information on this, see Lesson 3d: Scheduling reports.
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |