Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 9-Nov-11 11:20am
Edited 10-Nov-11 4:59am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
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.
  Permalink  
v2
Comments
RaisKazi at 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)

  Print Answers RSS
0 OriginalGriff 359
1 Maciej Los 290
2 Sergey Alexandrovich Kryukov 230
3 Shweta N Mishra 185
4 PIEBALDconsult 149
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,760


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 11 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100