Search code examples
c#.netcrystal-reports

Assign multiple values to a parameter in Crystal Reports


I have added a parameter to my report with the option "Allow Multiple Values" checked.

This is a status column (IE, Proposed, In Progress, Completed, Canceled), and I want the user to be able to select which (and how many) different OrderStatus to report on.

How I normally set parameters is:

report.SetParameterValue("@dtBegin", dtBegin.DateTime);

What I tried to do for the multiple values was something like this:

//pseudo loop
foreach(int intOrderStatus in intSelectedOrderStatuses)
{
    report.Parameter_OrderStatus.CurrentValues.AddValue(intOrderStatus);
}

I have checked it does add the values to the OrderStatus parameter, but when the report runs, the CrystalReports dialog pops up and asks me to enter values for the OrderStatus parameter. So it seems as though the values aren't "commited" to the parameter. I have done a number of searches and can't figure out why it's not working.

Thanks,


Solution

  • Just set the parameter value with an array of ints.

    report.SetParameterValue("@OrderStatus", new int[]{1,2,3});
    

    in the select expert you would use the in operator.

    {table.order_status_id} in {?@OrderStatus}