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

Subreport links 1

Status
Not open for further replies.

SeeBee

Technical User
Joined
Mar 18, 2002
Messages
31
Location
US
Here's what I want to accomplish, monthly. For April (lets call it April-1)I want to run a report on jobs closed, and the equipment used, and the total quantity for each piece of equip. Next I want to run another report (we'll call this one April-1b) using jobs that are still 'open', using the same fields in this report as April-1. April-1b will be a subreport, inserted into April-1, showing all results on one page(we'll call this Combo April 1 and 1b). Now here is my question. When I go to do the May reports must I create the subreport again, and then insert to the main report. Or can I just go into the 'Combo AJpril 1 and 1b' and indicate the 'May' date range to use on the main report, and then go to the subreport tab (even though it will still read April-1b on the tab)and indicate the same 'May' date range here and Run the report - will everything update correctly for May?. Thanks in advance for your help.
 
Why dont you generalize the report so that it will work for any month or date range?
I hope the sub report is linked with main report using some JOBID. In the same way you can pass same date range parameters say FROMDATE and TODATE which you use in Main report to the subreport.
 
The following may help - it's an extract from the Crystal Decisions knowledge base:..............................

Linking a subreport on a ranged date parameter



Synopsis

To avoid multiple parameter prompts, a report uses a ranged date parameter to prompt for a start and end date.

How can you link a subreport to the main report by this ranged date parameter, so the subreport contains the same dates?

The solution below is based on using a ranged parameter. However, if you are using 2 separate parameters--one for start date, one for end date--the process to link these to the subreport is essentially the same.

Solution


NOTE:

If you have two parameters, one for start date and one for end date, the linking procedure is the same. Skip Step 1, and follow the remaining steps, substituting the actual parameters for the @Start and @End formulas.

1. In the main report, create the following formulas:

@Start

Minimum({?DateRangeParameter})

@End

Maximum({?DateRangeParameter})

2. Go to the Edit menu and select 'Subreport Links'. This opens the 'Subreport Links' dialog box.

3. Select @Start from the 'Available Fields' box, and add it to the 'Fields to Link to' box.

4. Make sure the 'Select Data in subreport field based on field' check box is selected and the subreport's date field appears in corresponding drop-down box.

The 'Subreport parameter field to use' box should contain "?Pm-@Start".

5. Click OK to close the 'Subreport Links' dialog box.

6. Once more, go to the Edit menu and select 'Subreport Links'.

Repeat steps 3 and 4 for the @End formula.

The Subreport parameter field to use window should contain "?Pm-@End".

7. Click OK to close the 'Subreport linking' dialog box.

8. In the main report, go to the Edit menu and click 'Subreport'. This brings you to the design view of the subreport.

9. In the subreport, go to the Report menu and click 'Edit Selection Formula' and point to 'Record'. This opens the Record Selection Formula Editor. This is the record selection formula automatically created by the linking you did in steps 3 to 6:

{table.datefield} = {?Pm-@Start} and
{table.datefield} = {?Pm-@End}

However, you need to modify this formula, since this condition can never be satisfied. Modify the formula to:

{table.datefield} in {?Pm-@Start} to {?Pm-@End}

This formula passes the date range parameter values from the main report to the subreport. and eliminates the redundancy of duplicate parameter prompts.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top