cancel
Showing results for 
Search instead for 
Did you mean: 

How to link Date range from Main Report To Sub report In Crystal report?

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor

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

Former Member
0 Kudos

hi Abhilash,

I have tryed process given by you, but that not workes.

In my suberport i have use Date paramerrs which gives input to the Stored procedure.

Is it possible to share RPT file here by which u would get better idea about my issue?

--Swapnil

Former Member
0 Kudos

Hi Swapnil,

Yes you can share.

Change the extension of rpt file to txt and send

Former Member
0 Kudos

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.

abhilash_kumar
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

abhilash_kumar
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi,

Abhilash & Prathamesh Thank you for your replay.

I have created new SP by which without using sub report i can able to get required data on main report.

--Swapnil Vichare

Answers (1)

Answers (1)

0 Kudos

Roughly nine years later, this still holds true and I just used it to great effect on a fresh report!