Adding and Formatting Subreports
A subreport provides detail information from other tables.
You can create a subreport control to print another report as part of your report. An unbound subreport is not connected to the records in the main report: No relationship exists between the record source of the main report and the subreport.
If you always print two or more reports at the same time, include them as unbound subreports in a new, unbound report. When you print the new report, Access prints each of the subreports. Just make sure that all the reports require the same kind of paper!
Making a subreport
To create a subreport, whether bound or unbound, follow these steps:
- Create the report you plan to use as a subreport and save it.
Remember When you create this report, nothing about it says "subreport" - but any report can be used as a subreport. We like to use the word "subreport" in the names of reports that never print on their own; they only exist as subreports of other reports.
- Open the main report in Design view.
- Make space for the subreport control (also called a Subreport/ Subform control) in the Detail section of the report.
Drag your other controls out of the way.
- In the Navigation Pane, scroll down to the Reports section.
This gets you ready to drag the subreport from the Database window to the Design View window.
- Select the subreport-to-be from the Reports list in the Navigation Pane
and drag it into the Design View window, dropping it where you want the subreport to appear.
Access creates a subreport control on the main report, containing the report you selected. The Source Object property for the subreport control contains the name of the report that you dragged.
- Delete the label that Access created for the subreport if you don't like it.
Access creates a label for the subreport with the name of the report, but you can select it and delete it if you want.
- Move and size the subreport control.
Drag the control to the location you want and drag its edges to adjust its size.
- Click in the subreport control and then click the Property Sheet button on the Tools group of the Design tab on the Ribbon to display the Property sheet for the subreport control.
- Check the Link Child Fields and Link Master Fields properties on the Data tab of the Property sheet.
These properties contain the names of the fields that relate the main and subreports. The Link Master Fields property should contain the name of the field in the record source of the main report that relates to a field in the subreport. The Link Child Fields property contains the name of the matching field in the record source of the subreport.
Printing information from a subreport on the main report
Just as you can display totals from a subform on a main form, you can print totals from a subreport on the main report. When entering the expression in the textbox control on the main report, use this format:
= [subreport control name].Report![total control]
Replace subreport control name with the name of the subreport control. Replace total control with the name of the text box control in the subreport that displays the total. For example, the following expression may display the total extended price (price times quantity) for the records in the report that display in the Order Detail Subreport subreport control:
= [Order Detail Subreport].Report![Total Ext Price]
In this tutorial:
- Creating and Editing Reports
- What are Forms and Reports
- Creating Reports Automatically
- Running the Report Wizard
- Creating Simple Reports
- Editing Reports in Design View
- Adding page headers, footers, and numbers
- Adding sections that group your records
- Sorting the records in your report
- Calculating group subtotals and report totals
- Formatting Tips and Tricks
- Copying Forms to Reports
- Adding and Formatting Subreports
- Displaying Empty or Long Fields
- Creating Mailing Labels