• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1064
  • Last Modified:

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
0
Clif
Asked:
Clif
  • 7
  • 5
  • 2
1 Solution
 
mlmccCommented:
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
0
 
ClifAuthor Commented:
The list of values comes directly from the query that will feed the report itself.  I cannot add an "ALL" to that.
0
 
mlmccCommented:
Can you add a check box to the parameter screen?

mlmcc
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ClifAuthor Commented:
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)
0
 
mlmccCommented:
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
0
 
ClifAuthor Commented:
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.
0
 
Alan WarrenCommented:
Do we/you have access to the reports datasource, possibly a stored procedure.
Would need to find out what input params the sproc expects and how the sproc filters the results (the where clause).

I expect that crystal reports is doing something behind the scenes, when you specify "Add All" like this:
report.SetParameterValue("@dtBegin", dtBegin.DateTime);
report.SetParameterValue("@dtBegin2", dtBegin.DateTime1);
// or like this, passing in an array:
report.SetParameterValue("@OrderStatus", new int[]{1,2,3});

Open in new window

But in either case, crystal knows the expected params; and so would we, if we had access to the datasource SQL.

Alan
0
 
ClifAuthor Commented:
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"
0
 
Alan WarrenCommented:
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)
0
 
mlmccCommented:
What version of Crystal?
If it is CR 2008 or 2011 you could make the parameters optional.

mlmcc
0
 
ClifAuthor Commented:
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.  :)
0
 
ClifAuthor Commented:
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.
0
 
mlmccCommented:
Sound like you followed/used the suggestion from alanwarren.  I really think you should award points to his comment

mlmcc
0
 
ClifAuthor Commented:
You know, I thought I had seen that, but somehow missed it when I came back to grade.

Sorry, it's corrected.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 7
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now