on 08-16-2013 12:47 PM
Hi,
I have to link the date range from main report to sub reports.
In my report i have used one stored procedures for two sub reports with different record selection formula but with same Date range.
Here i have to pass the date range from main report to sub reports.
How to link Date range from Main Report To Sub report In Crystal report?
Hi Swapnil,
Here's how its done:
1) Create a formula in the Main report; call it Start_date:
Minimum({?Date_parameter})
2) Create a second formula in the Main report and call it End_date:
Maximum({?Date_parameter})
3) Insert the sub-report and then Right-click the sub-report > Select Change Subreport links > Move the Start_date and End_date formulas to 'Fields to Link to' area and make sure you uncheck the 'Select data in subreport based on field' option.
4) Edit the sub-report (Right-click > Edit) and insert a Record Selection formula to include the parameters from the Main Report.
Go to Report > Selection Formulas > Record:
{date_field} >= {?Pm-@Start_date} and {date_field} <= {?Pm-@End_date}
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
http://www.sendspace.com/file/g49fim
By using above link you can able to download my Crystal report with Sub report.
your solution is not working for my condition becouse that date range is an input for stored procedure becouse of that we can not able to add that in report Record selection formula of Sub Report.
Hi Swapnil,
You've not created a Date Range parameter. A Date Range parameter is a single parameter that has the From and To Date; what you have is a separate From and a Separate To Date prompt.
Anyway, try this:
Right-click the sub-report > Select Change Subreport links > Move the FromDate parameter in the Main Report to the 'Fields to Link to' area > From the drop-down on the bottom left that says 'Subreport Parameter field to use', choose '?@fromdate'.
Do the same for the 'ToDate' prompt and to the other Subreport too.
-Abhilash
Hi,
If you are able to correctly link the parameters then the record selection formula in the sub report should look like:
{?@fromdate}>={?FromDate} and {?@todate}<={?ToDate}
The prompting should happen only once and the date values that you select should be effectively passed to the main report and both the sub reports.
If for some reason, there is still multiple prompting or the data is the report does not seem to be filtered correctly, then check the format of date that is required by the stored procedure parameters. You might need to tweek the format of date key-ed in by the user in case this is observed. For that you'd need 2 formulas in the main report to convert the user-input date to the required format.
Let the forum know if thats the case.
-Prathamesh
Hi Prathamesh,
The Stored Proc he is referring to, actually has the From Date and To Date prompts as IN parameters. He is trying to link these prompts with the prompts in the Main Report - so no Record Selection Formula will be created.
The attached report clears the initial confusion!
-Abhilash
Roughly nine years later, this still holds true and I just used it to great effect on a fresh report!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.