When linking a subreport to a primary report, the program creates the link by using a parameter field.



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:



  1. 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.
     
  2. 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.
     
  3. 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.
     
  4. 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.
     
  5. The program then runs a subreport including only those gift records for the second customer.
     
  6. 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:

  1. Build the main report
  2. Go to Insert > Subreport
  3. Enter a name for the subreport and click on the Report Wizard button
  4. Select the new export file
  5. Click OK/Finish and place the subreport in the desired section
  6. Right-click on the subreport and select "Edit Subreport"
  7. Locate the field you will link the main report to and insert it somewhere in the report (it can be deleted after linking)
  8. Click on the Design tab to go back to the main report
  9. Right-click on the subreport and select "Change Subreport Links"
  10. In the top left box, select the field from the main report that will be linked to the subreport
  11. Click on the right arrow button to move the field to the top right box.
  12. In the bottom right drop down list, select the field from the subreport that will be linked to the main report
  13. 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.