A subreport is similar in most ways to a subform. The same methods for creating and managing apply, for the most part.
A subreport can be put on a form in Access 2010, 2013, and 2016 but not in Access 2007. A subform can go onto a report in all three versions.
Combining reports: An unbound report can be a container for two or more subreports, which do not have to be related to each other at all.
A report that is bound to a table or query can include one or more subreports that are bound to the same table/query or to a related table/query. Such subreports can be put into the Detail section, Group Header/Footer, or Report Header/Footer. Subreports cannot go into the Page Header/Footer.
Nesting: As with subforms, a report can contain subreports or subforms which are nested up to 7 levels deep. There is no limit on the number of subreports or subforms that are not nested.
The Subreport Wizard will open in either case and take you through a few choices to create a new report. The wizard automatically adds it to the list of Reports in the Navigation Pane. You can open the new report (your subreport) and make changes, just like any other report.
Problem:
Subreport is too wide and is cut off at the right.
A subreport is actually a report itself and has its own
properties, such as width.
The control that is showing the
subreport can have a smaller or larger width than what it contains!
Solution 1: Change with width of the control that displays the
subreport.
Solution 2:
Edit the subreport to fit in the available space.
You may need a separate copy of the subreport to edit just for the current use.
Be careful to notice whether you are changing properties for the control or for the subreport by checking the title of the Property Sheet.
Problem: Data in subreport not synchronized with
main report. All data shows instead.
The properties Link Child Fields and Link Master Fields are what link
a subreport to the report.
Check the following for the Link Child Fields and Link Master Fields properties:
Correct field names, spelled correctly.
Fields are in the record source.
(They do not have to appear on the subreport or report but they MUST be in the sources.)Use the actual field names and not the names of the controls on the report and subreport, which can be different.
Data types for the fields are the same or are compatible.
A common source of trouble - An AutoNumber field is only compatible with a Number field whose FieldSize property is set to Long Integer.
Problem: Column headings in subreport don't show
Subreports don't display page header or footer. If you put your
column labels in the Page Header, as is common, they won't show in a
subreport.
Solution 1: A subreport's Report Header/Footer do show, so you could put the column labels in the report's Header, IF you think the whole subreport will fit on one page.
Solution 2: If the subreport is longer than one page, use a Group Header in the subreport for the labels with the RepeatSection property of the group header to Yes. That will make the group header repeat on the page when the group does not fit on a single page.
Problem: Only one column in the subreport instead of
the number planned
This problem occurs when you made two particular choices:
Logically, this combination of properties lets the subreport control continue to grow in height. There is never a reason to move over to another column!
Possible Solutions:
- Change column direction: In the subreport, change Column Layout to Across, Then Down and, on the main report, leave the CanGrow property set to Yes for the subreport control. The subreport control will display multiple columns and expand as needed.
Disadvantage: You may not like having the records go across first. Records must be the same height.
- Don't let control grow: In the subreport, leave Column Layout set to Down, Then Across. On the main report, size the subreport control to fit the maximum number of records, and set its CanGrow property to No.
Disadvantage: If the number of records is greater than the maximum number you anticipated, records that don't fit in the subreport control will be truncated.
- Rethink the report: Instead of using a subreport, perhaps you could put the controls that show the data in the main report in a group header and put the controls that show the data in the subreport in the detail section.
![]() |
Step-by-Step: Subreports |
![]() |
What you will learn: | to copy and paste existing reports to be parent report and subreport to edit subreport to add a subreport using drag-and-drop to report's footer to create a new report to create a subreport with the Subform/Subreport tool to edit subreport to hide duplicate records to remove unwanted white space with Can Shrink |
Start with: , resource files, worldtravel-Lastname-Firstname.accdb from folder databases project4 as updated in the previous lesson
You will modify two reports that you created earlier. One will be the main report and another will be the subreport.
In the Navigation Pane, select the report Trips by Agents, which you
created in a previous lesson.
This report shows the agents with a list of their clients and the cost of each trip, after applying any discount. You saved several versions of this report while learning to create totals. This first version does not include any totals and is missing some formatting that you added later. You will add a subreport that shows the totals.
Problem: Report does not match illustration
Solution: Make changes to Trips by Agents to match. The Group Header should have a light blue background with the controls in the Group Header Back Style set to Transparent. The Detail section has a white background. All controls have Border Style set to Transparent.
You will modify one of your new reports to make it work better as a subreport about totals.
Delete controls and labels from Page Header, Staff.LastName Header, and Detail sections.
Resize those sections to zero height by dragging the bottom edge upward.
Size the control for the Grand Total value (in blue) to be the same as the one for the agent (in green) and align them evenly.
Switch to Print Preview.
Much better.
Save the report and close it.
[Subreport-Agents Trips Totals]
Drop it at the left of the Report Footer.
The Report Footer gets taller to hold the subreport but the subreport control is still too short to show much in Design View.
Access keeps the control short but automatically set the property Can Grow to Yes. When Access figures out what to show in Print Preview, it can set the height to the correct value to show everything.
Switch to Print Preview.
Just a few things to make neater.
Delete the label for the subreport.
It lies just above the edge of the subreport. When you select it, you will see its borders.
Next you need to edit the subreport itself.
But, the subreport control is too short for you to see most of the subreport.
Editing this is best done in the Design View of the original report. There is a button for that!
Close and save the subreport.
[Subreport-Agents Trips Totals]
You are back in Design View of the main report but the subreport shows just as a white rectangle.
The subreport control is the same size as before. Resizing the report does not resize the control!
Problem:
Report uses 2 pages
Solution: Resize the report to be 8" wide or less.
Close the report.
You have completed your first report that has a subreport!
Next you will create a report that has a subreport in the Detail section.
You will create a new report with information about agents and a new subreport that lists the agent's clients. The subreport will go in the Detail section of the main report.
The database already has forms that show all of the information about an agent. You will include only a few fields about the agent in this report so we can get to the subreport more quickly.
The previous lesson on subforms left us with an awkward listing of clients on the Agents with Clients form. A client showed up once for each trip. The duplication of names cannot be resolved easily for a form, but it can be fixed in a report. But first you will have to create the report!
In the Title column type the word "Agent" in the Criteria row.
Now the query will include all of the fields about Staff but only records for Agents. The records will be sorted in normal alphabetical order for names.
Switch to Print Preview.
There is a lot of extra space that gives you room for the subreport.
You do not have to have a report already created to put a subreport into your report. When you use the Subform/Subreport tool from the Controls palette, the Subreport wizard will appear.
Thinking: What fields do you need to show an agent's clients in a subreport?
Accept the default suggestion for how to link the report and subreport: Show Staff for each record... using StaffID.
The wording here is a bit tricky to understand. We want to see the client's names for a particular agent. What connects the main report to the subreport is StaffID from the Staff table. Remember you had to filter the Staff table to show just the people with a title of "Agent" for this report.
But the Clients table does not have a field that corresponds to StaffID. So what connects a client to a particular agent? It's all about Relationships! You already defined a relationship between Clients and Trips and between Trips and Agents. Access knows this and automatically connects the Agent with the Client for whom the agent did a trip. Sweet!
Click on Finish.
Access creates a subreport control and a subreport that contains all of the fields.
The subreport control starts at the top left of the rectangle you created with the Subform/Subreport but widens to show the full width of the subreport.
This subreport makes the report too wide for one sheet of paper. You do not need all of these fields to show.
The Navigation Pane shows the new subreport, Subreport- Clients for Agent.
Resize the subreport control's width by dragging its right edge to the left, leaving the control just as wide as the CFullName control in it.
Use the Property Sheet to set the Height property for the subreport to 0.5" .
Set the Height property for the Detail section to 1.7"
The subreport control will show scrollbars in Design View even though there is nothing out of view.
You have two choices about what to do if there are more clients than will fit in the subreport control. You can let the subreport control grow or you can let it show vertical scrollbars.
In the Property Sheet for the subreport, change the property Scroll Bars to Vertical Only.
This will leave the subreport control at its current height, no matter how many or how few clients there are to list.
The extra wide subreport made the whole report wider than 8". It won't fit on a page width now.
Switch to Print Preview.
It takes two pages to show the seven agents. Only three agents have clients in the database yet.
There may be some problems left to deal with.
Issue: The subreport for Hector Chavez grew taller instead of showing a scrollbar. The subreport control automatically set the Can Grow property to Yes.
Issue: The subreport for Hector Chavez, the first agent, lists Eric Bjorenson four times. He must have booked four trips. You will hide the duplications in the next section.
Issue: The clients are not alphabetized. For the agent Wilhelm Heinz, D G Garcia is listed twice, with someone else in between.
You will have to fix these issues to get the duplicates to hide.
Save the report.
[Agents, with Clients]
Report controls have a property that form controls do not: Hide Duplicates. When this property is set to Yes, duplicate entries will not show. But... there several other things that have to be set correctly or you won't get what you expected.
Open the Record Source with the ellipsis button .
The Query Builder
opens.
It shows the tables, queries, and fields that you chose in the Subreport wizard. But it also shows the Trips table! You did not pick that one. Access did something smart. It added the Trips table in order to join the Staff and Clients tables together.
Switch to Print Preview.
Is this better?
The subreport control shows the clients' names in proper alphabetical order and does not list anyone twice for the same agent. Hurrah at last!
Problem: Extra space or background color
The subreport form has extra space above or below the control CFullName.
Solution: Edit the form to remove the extra space.
Switch to Layout View.
Unexpectedly, the duplicate entries show as blank space in this view. Don't let that scare you. The Print Preview is still fine.