Link to home
Start Free TrialLog in
Avatar of Clif
ClifFlag for United States of America

asked on

Passing "All" Parameter Values from Visual Studio to Crystal Report

I have a report that I am serving up via a web page written in Visual Studio.

The report has several parameters which I am setting in code.  One of the parameters, however, has the "Allow Multiple Values" flag set as "Yes".  I want to be able to select all the values (the parameter is dynamic, so the values may change) as if the user had clicked the double arrow "Add All" button.

I've searched and have found many example of how to select one, two, or more values, but cannot seem to find a code example to select all the values.

TIA
Avatar of Mike McCracken
Mike McCracken

SInce you are providing the values through code how about allowing the user to select ALL or a check box for ALL.  You can then pass that into the report and in the selection criteria use

({?Parameter} = 'ALL' OR {?Parameter} = {YourFIeld})

mlmcc
Avatar of Clif

ASKER

The list of values comes directly from the query that will feed the report itself.  I cannot add an "ALL" to that.
Can you add a check box to the parameter screen?

mlmcc
Avatar of Clif

ASKER

To 200+ reports???

It seems to me there has to be some way of doing this other than rewriting/editing every report.

Is there a way of getting a list of available values from the report (Yes, I suppose I could query the view, but querying the report would be more accurate)
Do you have a separate parameter screen for each report?

Does selecting the first then moving down through the list and clicking the last one with the shift key held down select all?

mlmcc
Avatar of Clif

ASKER

I don't think you understand what I'm looking for.

There is no parameter screen in this context (I do have a related but separate question elsewhere on EE that should not be confused with this).

In the report I have several parameters, the specific one I am having trouble with is one where the "Allow Multiple Values" flag set as "Yes".  If this report is run within the Crystal Reports IDE, the parameter selection screen will show two list boxes.  The left list box contains all the values available for the parameter.  The right list box will contain the values selected.  In between the two boxes are two buttons.  The top button is a single arrow and will move the selected value from the left to the right.  The bottom button is a double arrow and will move all values from the left list box to the right list box.

All that is if you're looking at the report from within Crystal Reports.  But I'm trying to do this from within a web page.

In Page_Init, I have a line of code where the parameter(s) are set:

CrystalReportSource1.ReportDocument.SetParameterValue("Param1","My Value")

The problem is that this only sets the parameter to a single value.  There is code out there  which shows that I can replace "My Value" with an array to set several values to the parameter.  However the examples I have seen presume that the values are known ahead of time and are a fixed number of values.  I cannot use the examples, though, because the number of values may change and the values themselves may not be the same every time.  I need some way to specify "add all".  In other words act as if the double arrow had been clicked.
ASKER CERTIFIED SOLUTION
Avatar of Alan Warren
Alan Warren
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Clif

ASKER

I have access to the data source that feed the report, so I can (technically) get the list, put it in an array, and set the parameters that way.  

I'm hoping there is some other (read: easier/less code intensive) method of saying "Select All"
I don't expect there will be Clif, crystal made it easy via their GUI, but they would have had to do the grunt work somewhere before invoking the stored procedure.

Alan ";0)
What version of Crystal?
If it is CR 2008 or 2011 you could make the parameters optional.

mlmcc
Avatar of Clif

ASKER

Ok, I ended up creating code that read the list of available values from the database and put them in an array to feed the parameter.

It works.

Thanks to all for trying.  :)
Avatar of Clif

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for Clif's comment #a38363297

for the following reason:

If I graded in error, please point it out and I will try to correct.
Sound like you followed/used the suggestion from alanwarren.  I really think you should award points to his comment

mlmcc
Avatar of Clif

ASKER

You know, I thought I had seen that, but somehow missed it when I came back to grade.

Sorry, it's corrected.