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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameters & Sub Reports 1

Status
Not open for further replies.

doub123

Programmer
Jun 19, 2002
11
0
0
MT
Hi,

I've created a report with 5 sub reports. The reports aren't linked with the main report and the only reason I am using sub reports is because I have several parameters which are common throughout all the sub reports, hence these parameters are entered once and used by all sub reports.

My problem comes when trying to use a parameter in the selection criteria of the sub reports. I've added a date range paramter in the main report, and then declared a shared variable and assigned it to this parameter. The problem is when I try to use this shared variable in the selection criteria of a subreport it returns an error "shared variable can only be used while printing records".. adding a "whilePrintingRecords" then returns the error "The formulae cannot be evaluated at this time"

Does anyone know a workaround for this problem?

I hope I explained myself well.. thanks,

Andrew
 
Use Subreport Links to pass the parameter values to the subreports. In the Subreport Links dialog, select the parameter fields into the "Fields to link to" list. For each of these fields, check "Select data in subreport based on" and select the appropriate subreport data field. This way, CR will take care of the record selection formulas and you don't need shared variables.

Your container report must be based on a recordset with at least one record or your subreports will not run. If this is not the case, you can make the first subreport the container report and put the other subreports in its report footer.
 
Tanx,

That solved it!

It was quite simple, and I complicated it somehow. :)


Andrew

 
You can pass a date range or multi value parameter in CR8.5 but not in prior versions.

You will need to split it into seperate discrete values to get the values into the subreport Editor and Publisher of Crystal Clear
 
Hi Andrew,

I've just builded some reports with subreports like you described it. My way to success is:
1) creating the main report (that asks for the parameters)
2) creating the subreport AS A STANDALONE REPORT first, asking for it's own parameters, that have the SAME NAMES as in the main report
3) in the main report I choose "Include / Subreport" (hopefully functions are named so in english version, I usually work with the german version of CR) and select the subreport from the place where it is stored
4) then I DO NOT CLICK OK but change to flag "linkage". In the upper left container I choose the (first) parameter of the main report I want to pass through and with the arrow I make it appear in the upper right container. It is automatically marked.
5) In the lower left container I scroll down until I find the equally named parameter of the subreports and choose it.
6) If I want to pass more than 1 parameter I repeat steps 4 and 5.

Good luck !

Barbara
 
Barbara's method also works, and when the subreport is based on a parameter-using stored procedure or query, it must be used to pass the parameters correctly to the sp or query. Be sure to scroll the subreport parameters list to find the correct entry - CR will create a new parameter for you if you don't select the one that already exists, and that will not be passed through.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top