Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing MultiSelect Parameters to a SubReport

Status
Not open for further replies.

BobDennison

Programmer
Jul 28, 2010
24
US
I saw a thread that addressed an issue similiar to this one, but I am not sure how to adapt it to my situation, since it was dealing with a command, so I am posting this question as a new thread.

I am using Crystal 2008 service pack 2.

Here is my situation. I have a main report that contains 3 sub reports. Each of the subreports are using the same data source, but retrieving the data using different sets of criteria. I have 4 parameters on the main report: 'Begin Year', 'End Year', 'County' and 'City'.

Originally the users just wanted to be able to select 1 county and 1 city within that county. No problem, that worked fine. Now they have decided they want to be able to select multiple counties and multiple cities. So, I changed the county and city parameters so that they can accept multiple values. When you select, say 5 counties, the main report creates an array of values, as I would expect, but it passes this data to the sub reports as a string.

I tried to use this string using the select expert by saying 'is one of' and then the variable that is being passed to it from the main report. If you look at the SQL that is generated by Crystal it shows '=' to the variable. Now, this is never going to work because this variable is a string that contains the 5 counties that were selected separated by a comma and a space. Ugh!!

So I tried creating an array variable in the sub report and then splitting the variable passed to it into it's separate values. This didn't seem to work very well because I can't use an array in the select expert. I even tried manually editing the selection criteria and putting the array in there. That didn't work either.

What do I do now? Any help in solving this problem would be greatly appreciated.

Thanks,
Bob

Tearing my hair out! (What's left of it anyway).
 
Please explain in what main report sections the subreports are located. Are you expecting the subreport results to be returned on change of some group in the main report? If so, please explain your group structure in the main report.

-LB
 
I have set up several Report Header sections where I display information about the report, give contact information and collect the parameters. Then I have put the sub reports in 3 different Report Footer sections. Each of the sub reports could be stand alone reports because they each connect to the data source and collect their own sets of data. There is no group on the main report.

The main report is connected to the data source, though, so that it can get the data to populate the dynamic parameters. That is the main function of the main report. Once the user has selected the beginning year, ending year, county and city from the user and passes it to the sub reports it is basically done, the sub reports go get the data, based on each of their own sets of criteria. There is no manipulation of the data by the main report once the sub reports are done, so they don't need to pass back any data.

I hope this helps.

Thanks,
Bob
 
You should create the same parameters within each subreport, add them to the subreport record selection formula, and then in the subreport linking screen, link the parameters to each other. Be sure to use the dropdown in the lower left corner to select the {?Parm} instead of the default {?pm-?Parm}.

-LB
 
In the main report the parameters are dynamic. Do I make the ones in the sub reports dynamic as well or are they static?
 
I'm not actually sure without testing it. Try static parameters first on one sub and see how it goes. Seems like that should work.

-LB
 
This is working great now. Thank you so much for your help.

Bob
 
Did the static parameters in the subs work then?

-LB
 
Yes they did. I tried both ways and the static parameters worked but the dynamic parameters prompted me again for input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top