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.

Result = InfoStore.Query("Select Top 1* From CI_INFOOBJECTS Where" +

    "SI_PROGID = 'CrystalEnterprise.Report'");

ReportObject = Result.Item(1).PluginInterface("");


Param = ReportObject.ReportParameters.Item(1).CurrentValues.Item(1);

if (Param.IsSingleVaule)

{

    //Check if a string value is being used.

    if (Param.Valuetype=6) Param.Value = "Some String";

}

if (Param.IsRangeValue)

{

    //Check if a string value is being used.

    if (Param.Valuetype=6)

    {

        Param.FromValue = "A";

        Param.ToValue = "Z";

    }

}

Example 2 (Adding new values)

This example deletes all of the parameter's current values and adds new ones.

Result = InfoStore.Query("Select Top 1* From CI_INFOOBJECTS Where" +

    "SI_PROGID = 'CrystalEnterprise.Report'");

ReportObject = Result.Item(1).PluginInterface("");

CurrentValues = ReportObject.ReportParameters.CurrentValues;

CurrentValues.Clear();

NewSingleParam = ReportObject.ReportParameters.CreateSingleValue();

NewSingleParam.Value = "X";

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

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