Inserting Subreports

To insert a subreport into your report, right-click a blank area of the report, and select Insert ^ Subreport from the right-click menu, which will open the dialog shown in Figure 3-37.

You have three options for adding a new subreport: First, if the report you want to add is a report that exists in your current project, you can use the drop-down list at the top of the dialog to select the report.

Figure 3-37

Second, if you want to add an existing report that has been saved outside of your project, use the Choose a report option and the Browse button to locate the report you want to add as a subreport.

And finally, if you want to create a subreport from scratch, select the Create a subreport option, enter a name for the subreport, and click the Report Expert button to launch the Standard Expert, which we looked at in Chapter 2, to create your report. The Standard Expert is shown in Figure 3-38.

Once you have selected or created your report, click the Links tab to open the dialog shown in Figure 3-39.

Figure 3-39

Using this dialog, you can create a linked subreport, where the subreport details will be filtered by a field in your main report. To select a field from the main report, highlight the field and click the right-arrow to add it to the list of selected fields. Then, using the drop-down lists at the bottom of the page, select the corresponding field in your subreport.

Remember, you don't actually have to specify any links at all, but if you do not, the subreport will not be filtered — that is, it will run for all records in the subreport, wherever you place it. If you place an unlinked subreport in the details section of your main report, for example, it will run once for every detail record.

When you are finished, click OK to return to the report designer; your subreport will be attached to the tip of your cursor, and you can click to place it on your report. It will appear as a box with a border around it and a label for the subreport name.

Was this article helpful?

0 0

Post a comment