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

Passing Parameters to Sub Reports

Status
Not open for further replies.

TEM3

Technical User
Dec 6, 2004
324
US
Crystal Reports 8.5:

I'm running out of hair to pull (out).....

Two reports. Exactly the same, only the second one (I want to run as a subreport) has one less group, the office location group. Therefore the second report will server as a "combined" report.

Two parameters: {?sdate} and {?edate}. I tried with and without these parameters in the subreport.....

I position the second report (Insert Subreport) into the Report Footer of the main report. I right click on the subreport box. I choose Change Subreport Links. I click on ?SDate and ?Edate. I check "Select data in subreport base on field:" (?Pm-?SDate/?Pm-EDate appears in the "Subreport parameter field to use:" box). But in the drop down under the check, my original parameters do not appear and there is nothing to select that will work.

What can I be doing incorrectly?? I know I have had this work before.
 
Here is a better way:

First, change your parameter fields from two each of type date to one of type date and check the range box. That will allow you to work with one parameter rather than two.

Now, somewhere in the main report header create the a formula with the following expression:

Whileprintingrecords;
shared daterange variable mydates := {get_dates}

You can format this with the color of white so it does not show on the paper.

Place the sub report in the report footer but do not even try to link it.

In the report header of the sub report add the following to the query formula:

Whileprintingrecords;
shared daterange variable mydates := {get_dates};
{table.field} >= minimum(mydates) and
{table.field}<= maximum(mydates)
and.....
... the rest of the stuff


In the



Howard Hammerman,
Crystal Training and Crystal Material
On-site and public classes
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
Remove the original parameters from the subreport and in the 'Select data in subreport based on field' box select the database field you wish to filter.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
I should also add that doing it this way the filtering will be passed to the database and improve performance.

Using a formula containing WhilePrintingRecords will force the filtering to be done by crystal on the local PC.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
You need to make sure that your parameter in the main report is of the same datatype as the field in your subreport. If the subreport field is a datetime, then it won't appear if your parameter is a date. Once you get the field(s) for the subreport to appear for linking, and you have linked the reports, go into the subreport record selection area and change the signs in the formula from "=" to ">=" and "<=".

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top