Modifying report parameter values

Once you have retrieved the report and the parameter you wish to modify, you may modify the parameter in one of two ways:

Example 1 (Modifying the CurrentValues Property)

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)

If .IsSingleVaule Then

    'Check if a string value is being used.

    If .ValueType = 6 Then .Value = "Some String"

End If

If .IsRangeValue Then

    'Check if a string value is being used.

    If .ValueType = 6 then

        .FromValue = "A"

        .ToValue = "Z"

    End If

End If

End With

Example 2 (Adding new values)

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;

CurrentValues.Clear();

Set NewSingleParam = ReportObject.ReportParameters.CreateSingleValue

NewSingleParam.Value = "X"

ReportObject.ReportParameters.Item(1).CurrentValues.Add NewSingleParam

Set NewRangeParam = ReportObject.ReportParameters.CreateRangeValue

NewRangeParam.FromValue = "A"

NewRangeParam.ToValue = "Z"

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