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!

Paramaetr passing to Sub Report from Main Report

Status
Not open for further replies.

rubinap

Programmer
Aug 26, 2005
6
CA
Hi ,

I am relativly new to Crystal Reports and I am stuck.

I am creating 1 main report with 5 sub reports. All the sub reports take a date as a parameter - on the bases of which the SQL queries are built & executed.

What I want to do is accept the date as a parameter in main report & pass it to the sub reports as a parameter. Right now when I try to do that - In the main report, when select the sub report through the "SubReport Link" option - & select the date parameter(of main) -- there is no corresponding parameters listed for the sub report.

How do I solve this ?

Rubina
 
The first thing I would check is if the type of field is different in the subreports. For example, if you have a DATETIME field in the main report and the subreports are DATE fields, they won't match.
In the past when I've had this happen, I've created a formula to change the type of field to match. If you need your date to be a datetime, something like this:

formula name: datetime
Code:
BeforeReadingRecords;
datetime({?StartDate},(time(0,0,0)))

You can then use the edit subreport links to match that field to the subreport date field.

If that is not the issue, hopefully someone else has an answer.
 
You can either link the parameter to the datefield in the subreport and then in the subreport record selection area, write the selection formula so that it uses the parameter(s) correctly, as in:

{table.date} >= {?pm-?startdate} and
{table.date} <= {?pm-?enddate}

(The default sets the date = to the parm). Or, you can create the corresponding parameter within the subreport, and then link {?date} from the main report to {?date} in the subreport. In this case, you have to use the dropdown to select {?date} instead of {?pm-?date}. You didn't say what version you are using. In 8.x, this dropdown would be in the bottom left corner of the edit subreport links screen.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top