Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: , +
Hi,

I am trying to learn how to use Crystal Reports and I have set up a parameter in my report to allow multiple values. This works well except that it prompts the user to enter a value or values when I run the report. What I would really like is for the default action to be all values are displayed with no user prompt. If he wants to filter to a subset then he can. I have searched but can not seem to find how to do this anywhere.

Thanks in advance for any advice,

Preston

Surely there is a way to programatically set the value of the multi-parameter to all?
Posted
Updated 10-Nov-11 3:59am
v2

With Crystal Report, you can pass the parameter via code (bypassing the Crystal Report UI to input parameters). This looks to be what you are trying to accomplish:

VS 2010 - Passing Parameter Programatically to Crystal reports[^]

The other option would be to create your own UI and then pass the selected values to the report using either a selection formula or parameters.
 
Share this answer
 
v2
After a lot more digging and experimentation I found the pieces of the puzzle I needed to make the report behave like I wanted. Here are the key pieces. To set the parameter value programatically you do the following.

rpt.SetParameterValue("parm", "*");

Then in the Crystal Reports menu select Report->Selection Formula->Saved Data...
add the following formula
VB
if HasValue({?parm}) Then
    if {?parm} = "*" Then
        True
    else
        {?parm} = {Table.FieldEquatedToParm}
else
    True

This will allow the report to come and display all the values without prompting the user to enter a value. Then if the user decides they want to filter the report they can use the parameter panel to choose a filter value. The formula get kind of nasty if increase the number of filterable columns though.
 
Share this answer
 
v2
Comments
RaisKazi 11-Nov-11 13:17pm    
Edited: Formatted with "code" and "pre" tags.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900