Your report can show a number of different totals. A "total" can be any of the aggregate functions, including Sum, Avg, Max, Min, Count Records, Count Values, Standard Deviation, and Variance. So many choices!
Whole report
Running Sum in each record
It is important to make it clear which total is which!
The illustration shows a report which has two groups, EpisodeID and YearAcquired. There is a group total for each, plus a grand total for the report. A running sum in the Detail section numbers the items over the whole report.
Note on Formatting of Calculations:
It is often important to make it clear in the report what parts are calculated. Most often you would use different formatting for the text/numbers or for the control.
Your report can easily show totals like sums, averages, and counts based on the fields in the report's source. You can total each group in a Group Header or Footer. You can total the whole report in the Report Header or Footer.
Method 1: Easy
Method 2: When 'Easy' won't work
Set the control source for the new control to an expression that calculates the total that you want.
General Syntax: =Function([FieldName])
Examples: =Sum([Price]) or =Avg([Price]) or =Max([Price]) where the
field named Price is in the report's source.
The field that you are totaling is usually shown in
the Detail section but does not have to be.
What will be totaled: Group or Report?
It depends on which section you put the
new control. If it is in a group header or footer, then the total is over
that group only. If it is in the report header or footer, then the total
is for the whole report.
Special Case: Counting
records with Count(*)
For counting records, it is almost always better to use the expression =Count(*) instead of an expression based on a field name, like =Count([Price]).
The two expressions do not always produce exactly the same results. =Count([Price]) will not count
records that do not have a value in the Price field, but =Count(*) will! You almost always will want to count ALL records.
Totals Per Page? The methods above will
not work to calculate totals for each page. Such a total cannot be calculated until after the report is
formatted for print. So, the page header and footer will not accept an
aggregate function like Sum or Avg or Count. It is possible to use Visual Basic code to
create page totals: Sample Code
from Allen Browne that you could adapt
Microsoft article for Access 2002 that you could adapt
To sum the price paid for all the items in a group, you can use the Group, Sort, and Total pane.
In the illustration
from the Star Wars Collectibles
database, the records are grouped on the field EpisodeID. The total is the Sum on the AmountPaid field.
The control source for the new control is the expression =Sum([Amount Paid])
You can only pick a field that is in the report's source. The field is usually shown in the Detail section, as it is in this example, but it does not have to be in the report for the total to work!
The
report shows a total in the footer for each group and a grand total for the whole report.
When you have two or more group levels, you can do totals for each group level. The report as a whole can also have a total. You do not have to use the same aggregate function for all of the totals.
Labeling: It is important that the totals are clearly labeled so
you can tell which total goes with which grouping. Staggering the totals
across the page usually helps. Formatting different levels differently
and/or using divider lines also helps.
The Group, Sort, and Total pane shows two groups and one additional sort. The same calculation goes in each of the three controls for totals =Sum([Amount Paid]).
Access can figure out which records should be totaled for each subtotal. Group Headers/Footers are so helpful!
The report shows a subtotal for each group within each episode, a subtotal for each episode, and then a grand total for the whole report. The order of fields in the dialog is important!
A running sum shows a total that increases with
each record or with each group. The illustration shows an accumulating total with each
record.
In the illustration, the field AmountPaid is used as the control source for two controls, which create the columns Amount Paid and Cumulative Total. The total is accumulating over the whole report.
The only difference between the two controls is that the Running Sum property is set to Over All for the Cumulative Total column.
How to number each record with a
Running Sum:
Set Running Sum property to Over All to continue numbering in sequence for the whole report, as in the illustration.
Set Running Sum to Over
Group to restart numbering with each group.
![]() |
Step-by-Step: Totals - Simple |
![]() |
What you will learn: | to count records with the Count(*) function for groups and the whole report to use the Report Wizard to create a simple SUM for group and report to edit the report to create a running sum in the Detail section to number records with Running Sum |
Start with: , resource files worldtravel-Lastname-Firstname.accdb from folder databases project4 as updated in the previous lesson
World Travel Inc. wants your report to show how many clients are in each country. For that you can add totals to your report that use the Count(*) function.
After finishing up the client report, you will create another report based on the Trips table and create some simple totals for it.
The easiest way to count records is to use the special function Count(*).
You will create a new version of an existing report that groups the clients by country and postal code. You will add a total that uses the Count(*) function to count the number of records in each group and in the report as a whole.
In the Group, Sort, and Total pane, change the PostalCode group to show a footer.
Country already is showing a footer.
By default the new footer will show alternating back color, which we do not want.
Click on the Text Box button on the ribbon tab Report Design Tools: Design.
The pointer changes to the text box shape .
Click in the Country footer at about the
2" mark.
Type in the label for the new
control: Total for Country:
Point of Confusion:
Alignment
The total's text box in Design View looks like it is aligned to the left. But the total values
are numbers, which are aligned by default at the right. In the Design
View you see an expression, which is text. Text is aligned by default
to the left. Confusing!
Similarly, add a total to the PostalCode footer that counts the number of records in each
group.
You may need to drag the bottom edge of the footer down to make space for the new control.
Add a new text box to the Report Footer.
You may need to drag the bottom edge of the footer down to make space for the new control.
Next you will use the Report Wizard to create a report, Trips by Clients, which will show a total amount that each client has spent on trips. You will pull fields from two tables and a query. Of course what the Report Wizard produces will need some adjustments.
Click on the button Summary Options.
The Summary Options dialog opens.
Check the box to Sum on Price and leave selected the default choice for what to show, Detail and Summary.
Name the report Trips by Clients and click the Finish button.
The report opens in Print Preview. The default formatting and layout is a bit different depending on which version you are using. Access 2010, 2013, and 2016 produce very similar reports. But all versions need work! Some controls are too narrow to show the data in them. The Summary label is messy-looking. Some labels overlap. There is wasted white space.
The Report Wizard gets the fields you chose onto the page. But, does it guess well about how wide each field really needs to be? It's a start, but you will nearly always want to make changes.
What needs fixing:
Sorting of group: The clients are not sorted alphabetically but are listed in the order that they appear in the Clients table, that is, by their ClientID. (Not all clients have trips entered in the Trips table).
The query from which you took the field CFullName sorts the full names alphabetically. The report is apparently ignoring that! This kind of problem will have to wait until the next lesson.
Change the Width of the following controls:
CFullName control = 2"
StartDate = 1"
Switch to Print Preview.
The report includes a total for each grouping and for the whole
report.
Inspect the preview carefully. Make sure all changes were made and that all values are showing in the records.
Where necessary, change the Alternate Back Color for the group header and Detail section to No Color or to match the Background property.
Resize the Summary control and position it beside the group total.
Switch to Print Preview.
Better. It's not perfect, but it will do for now.
Your print preview may look a bit different from the illustration, depending on your version of Access and the exact sizes you chose for controls and sections.
While it is not particularly interesting for this report, let's practice creating a running sum in the Detail section. This method can be used for situations where you want to total a calculated control (as we will do in the next lesson).
Drag the matching labels to the left also.
Drag the pasted label to the right to be a column label above the new text box.
Where it pastes: Objects
pasted in Design View appear at the upper left of the section that was
selected when you pasted. They can be hard to see if they overlap
other objects or are small, like thin lines.
Add a label to the center of the Page Footer containing your name.
(Hint: Type your name in the label and resize to Best Fit. Center the control around the 4" grid line.)
The new column shows a total that increases with each new record in the group. The last record in a group will have the same total as the group's total, which was calculated separately.
In this report the column resets to zero for each new group. If the Running Sum property for the control is set to Over All, then the total will not reset but will keeping accumulating for the whole report.
The Running Sum property can also be used to number each record, either within a group or over the whole report.
Next you will number each trip at the left over the whole report. Why? For practice, of course!