Article ID: 208835 - View products that this article applies to.
This article was previously published under Q208835
Moderate: Requires basic macro, coding, and interoperability skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
This article demonstrates how you can use a total from a subreport on a main report, and how you can display a total for all the subreports.
If you use an expression similar to
=Sum([MySubReport].Report![Product Sales])on a main report to sum a reference to a subreport control that contains a subtotal, you receive a
error message. This error message occurs because the Sum() function (and the other aggregate functions) can reference only fields, not controls. To avoid this error, place the sum expression in the subreport's report footer, and then reference that expression in the main report.
Displaying the Total from a Subreport on a Main ReportCAUTION: If you follow the steps in this example, you modify the sample Access project NorthwindCS.adp. You may want to back up the NorthwindCS.adp file and follow these steps on a copy of the project.
To display the total from a subreport on a main report, follow these steps.
Displaying a Total for All SubreportsTo display a grand total for all subreports, you can use either a second subreport or a control's RunningSum property.
Using a Second SubreportYou can use a second subreport to display a grand total. When you add a second subreport to a group footer section, make sure to link the subreport to the grouped field so that the subreport displays the total for that group. If you place the subreport in the report footer section, do not link the subreport to the grouped field so that the subreport displays a total for all the records.
The following example demonstrates how to use a second subreport to display a grand total on a main report:
Using the RunningSum property:To use the RunningSum property to display a grand total on a main report, follow these steps:
For more information about the RunningSum property, click Microsoft Access Help on the Help menu, type runningsum property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
For additional information on calculating a running sum, click the article number below to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/208850/EN-US/ )ACC2000: How to Sum a Calculation in a Report