Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Business Objects: Crystal Reports 4 Other topics FAQ

Report Development

How do I pass date parameters to sub reports and use them in the selection criteria?
Posted: 6 Dec 01

he following was developed for Crystal version 7 as there was a problem in linking dates.

1. Introduction
 This document describes the steps that will allow nested sub reports to share some or all of the selection parameters of the parent report.
 
 This document shows reports that will share a date range as their parameters as this is a common link between reports.
 
 The instructions assume that both the Primary and Sub reports have been completed and that the sub report has been inserted into the footer of the Primary report.
2. Instructions
2.1. Set up the Primary Report
 In the primary report, create 2 parameter fields called startdate and
 enddate.  You do not have to show these fields in the report.
 
 These parameters are then shown in the report fields list as ?startdate and ?enddate.
 
 Then create 2 formulas called startdate and enddate.  The startdate formula should only contain the report field value {?startdate} and the enddate formula should only contain the report field value {?enddate}.
 
 These Formulas are then shown in the report fields list as @startdate and @enddate.
 
 These formulas are required because you cannot create a subreport
 link based on a parameter field.
 
 You must then edit the selection criteria for the main report to include the data range.  Go to the menu options Report|Edit Selection Formula|Record and enter/include the following record selection criteria:
 
 {table.datefield} >=  {@startdate} and {table.datefield} <= {@enddate}
2.2. Set up the Sub Report
 Create the same 2 parameter fields and the same 2 formula
 fields in the subreport.  These do not have to be on the actual report.  
2.3. Link the Reports
 To link the reports go to the menu options Edit|Subreport Links.
 Select the formula @startdate from the available fields.  This will activate field link section at the bottom of the screen.  Remove the tick from the checkbox to deactivate this area.
 
 Repeat with the formula @enddate.  Then select OK to close the window.
 
 Now edit the sub report.  The above procedure will have created two parameter fields in the sub report,
 {?Pm-@startdate} and {?Pm-@enddate}.  These parameters represent the range value passed from the main report.
 
 You will now have to edit the record selection formula for the sub report.  
 Select Report|Edit Selection Formula|Record from the menu and change the record selection to
 read:
 {table.datefield} >=  {?Pm-@startdate} and {table.datefield} <= {?Pm-@enddate}.
 
 Now, when the report is refreshed, the user will enter in the start and end dates in the main report and these values will populate the record selection formula in the subreport.
 

Back to Business Objects: Crystal Reports 4 Other topics FAQ Index
Back to Business Objects: Crystal Reports 4 Other topics Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close