When a subreport link field is selected, the program creates:
- A parameter field in the subreport which is then used to retrieve values passed to it by the primary report
- A record selection formula for the subreport using the parameter field
- The selection formula limits the subreport to those records in which the link field is equal to the parameter field value.
When the report is run, the program finds the first primary field record it needs and passes the value in the link field to the parameter field in the subreport. The program then creates the subreport with record selection based on the parameter field value. Here is an example:
- You create a report that shows constituent data and a subreport that shows gift data and then you link the two reports using the Constituent ID field.
- When running the report, the program finds the first constituent record it needs and passes the Constituent ID value from that record to the subreport parameter field.
- The program runs the Gifts subreport. Since the subreport selection formula selects only those records in which the Constituent ID value is equal to the parameter field value, and since that parameter field value is equal to the Constituent ID in the first record in the primary report, the subreport contains only those records that have the same Constituent ID. Namely, those records that are gifts for the first constituent.
- When the subreport is finished, the program locates the second record it needs in the primary report, prints the constituent data, and then passes this constituent's ID number to the parameter field.
- The program then runs a subreport including only those gift records for the second customer.
- The process continues until the report is finished.
The parameter field manipulation takes place behind the scenes. Simply pick the fields that will link the primary report with the subreport and the program does the rest. The values are passed without the parameter field prompting you for a value.
Steps for linking the subreport to the main report:
- Build the main report
- Go to Insert > Subreport
- Enter a name for the subreport and click on the Report Wizard button
- Select the new export file
- Click OK/Finish and place the subreport in the desired section
- Right-click on the subreport and select "Edit Subreport"
- Locate the field you will link the main report to and insert it somewhere in the report (it can be deleted after linking)
- Click on the Design tab to go back to the main report
- Right-click on the subreport and select "Change Subreport Links"
- In the top left box, select the field from the main report that will be linked to the subreport
- Click on the right arrow button to move the field to the top right box.
- In the bottom right drop down list, select the field from the subreport that will be linked to the main report
- Click OK
NOTE: If a subreport is linked and you click the Print Preview button on the Standard toolbar (from the Subreport Design tab), the program runs the subreport on its own, without waiting to receive a parameter field value from the primary report and without evaluating the tab text formula. In this case, the program displays the Enter Parameter Values dialog box and prompts you for a value.
The value entered in the drop-down box is the value the program uses to run the subreport.