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

Problem Passing Parameters to Subreport

Status
Not open for further replies.

itprsn

MIS
Jan 6, 2004
40
US
I'm running Crystal Reports 8.5 and am having a problem with the parameters. I have a primary detail report and a subreport that is a summary report. My parameters are identical for both reports - from date, to date and product line. When I edit subreport links it attempts to link ?from date to ?pm-?from date, ?to date to ?pm-?to date, etc. This linking seems not to work - when I go to run the detail report it prompts for from date, to date and product line twice, once for the primary report and once for the subreport. Any ideas on what I am doing wrong with this linking? Am I supposed to have a pm-from date field or something like that on the subreport?? Thanks...
 
Go to edit->subreport links, and click on the "Subreport Parameter to Use." In the drop down box, below "?Pm-?from date", you should see "Parameter Fields" and "?from date" listed below that. Try using these fields to link on instead of the "?Pm" fields.

-LB
 
When I go to "subreport parameter field to use" and click the drop down box I don't get any other options. My only choice is ?pm-?from date. Somehow it doesn't "see" my other parameters from the subreport - ??
 
Are you sure that the parameters in the main report and in the subreport are both defined as the same datatype--date?

-LB
 
When you go to edit->subreport links, you need to first move {?from date} from the "Container report--available fields" box into the "field to link to" box on the right, and then the {?from date} should appear in the box in the lower left hand corner, below the {?Pm-?from date}. Also, I'm assuming that you have created the parameter in your subreport and used it in the record selection formula in the subreport.

-LB

 
PS - As you try different things, you should be refreshing the report and subreport.

-LB
 
I see the additional drop down box below the ?pm-?from date box. I'm not sure why but when I go to choose from date from the lower left hand box it has two options ?from date or ?from_date. Neither option seems to work and I don't see any differences between how the date parameters are set up on one report vs. the other. The date logic exists in both reports, looks and works fine.

In the case of product line I can set the lower left hand box to product line and it works fine. So any problems that you can think of with date fields, why they wouldn't work the same??
 
I think I found the source of the additonal from_date and to_date. Somehow the subreport that was attached to the primary report had additional parameters and additional code (from_date and to_date) farther down in the record selection formula editor. Not sure exactly how that happened but when I cleaned it up and set the dates equal to the dates, etc. it now works. Thanks for your help!
 
I joined the forum just to thank lbass for this post.

I was having similar problems with Crystal Reports, and had even run into the problem of it asking me twice from the parameter date (once for the primary report, once for the subreport). I had almost hit upon the solution, but my linking was wrong. I was linking back to the primary report parameter value in the 'Subreport parameter field to use' box instead of to the parameter in the subreport.

Thanks for you help.
Gary Baker
 
EXAMPLE:

parameters StartTime and EndTime exist in the primary report with datatypes of DateTime. I want to pass the parameter values entered for these to my subreport so that it can use them to determine its data output.

First I create parameters StartTimeSub1 and EndTimeSub1 in my subreport, making sure that they too have a datatype of DateTime.

Next I go back to the primary report and click on Edit, Subreport links.

In the 'Container Report field(s) to link to' box I move the StartTime and EndTime fields from the primary report over to the 'Field(s) to link to' box.

Under 'Subreport parameter field to use' I find 2 entries, '?Pm-?StartTime' and '?StartTimeSub1'. I select the subreport parameter, ''?StartTimeSub1'.

I repeat this process for the EndTime parameters.

The StartTimeSub1 and EndTimeSub1 parameters in my subreport will now be populated with the values entered for StartTime and EndTime when the primary report is run.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top