Click here to Skip to main content
12,404,895 members (70,521 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Visual-Studio VS2010 , +
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 10:20am
Updated 10-Nov-11 3: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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 11 Nov 2011
Copyright © CodeProject, 1999-2016
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