Report Totals
By Richard Rost
2 days ago
Calculating Subtotals and Grand Totals in Reports
Need a subtotal for each group and one grand total at the end of your Access report? I'll show you where to put the Sum expressions, how the Group Footer differs from the Report Footer, and how to check the totals in Print Preview. I'm using an accounts payable report, but the same idea works for other grouped reports. For the full database build, see my Access Payables Seminar at https://599cd.com/Payables.
Related Video: https://youtu.be/yKKz9e3nGuE
Keywords
calculations in microsoft access reports, microsoft access report totals, access report subtotal, access grand total, group footer, report footer, sum function, accounts payable report
Subscribe to Report Totals
Get notifications when this page is updated
More InformationTranscript I want to make some totals. We can turn this guy off, by the way. Don't click that X. I hate how they did this. One of my pet peeves with Access.
Hey, Access team, change this. This is too close and similar to that. This means to close the grouping pane. This deletes that grouping level or sorting level. I hate that. Do something different. Put it over here, maybe. I don't know. Make sure you click on that guy to close that grouping pane.
I am going to copy one of these guys. Copy, click, paste. We had this discussion in the forums, by the way. Let me delete that. Somewhere, somehow, with Windows 11 and later versions of Access, you can't copy and paste anymore. See, copy, click, paste. It won't let you copy multiple text boxes. I don't know when this happened. I don't know how to fix it. It's some kind of bug. It's floating around, with people aware of it, but you have to do it one at a time. It stinks. Copy, click, paste. Slide you over here.
If you want to put a line in here, you can report design. This is the kind of fluff that I usually add later, but while I'm thinking about it, sometimes I do it. I'll put a little line right there. Drag it out. There we go.
Now, this guy is, let's take a look at its data. It's past due. This guy is going to be equal to the sum of past due. Not DSum, just the regular Sum function. It's summing everything above it. So, for a group footer, it's everything in that group.
While you're at it, change this. Let's call this group past due. Let's go payee past due, because this is for the payee past due. That makes more sense. Save it. Let's take a peek. Make sure that's working. Good. One hundred. Zero, zero.
We just need to do a little formatting now. So, back to here, and let's go format as currency. Make sure that works. Yep, looks good.
A lot of times for these reports, I set decimals to zero because just seeing all these .00s is all over the place, unless it's important to you. For me, personally, usually for a report like this, just like the IRS, I don't care about pennies. So, I am going to select all of these. I'm holding down the Shift key and clicking individually. We're going to set decimal places to zero. Then take a peek. That looks better.
Maybe for these footers here, we'll bold them. Copy this guy. Copy, paste, paste. See? Copy, click, paste. There we go. It's not you. It's not me. It's just weird.
Equals the sum of due in seven, and this will be payee due in seven. Then we'll bold it.
Now, we'll do the same thing for these guys. Copy, paste. See? Copy, paste. There we go. Equals the sum of due in 30. Payee due in 30. Bold it.
And one more. Copy, paste. Oh, it did it the first time then. There. Equals the sum of that, and it's the payee over 30. Bold it. Save it. Close it. Open it. Open it. Looks good. Beautiful.
Well, we have to format currency, of course. Right-click, Design, Maximize. Click, click, click. Format currency. These guys don't have a dedicated format in here because they're inheriting the format from the query. But you can, if you want, come in here and just force that to currency as well. Save it. Preview. Looks good.
How about a total down here in the bottom for the entire report? Well, it's going to work pretty much the same way. We're going to put it in the report footer, not the page footer. It's possible to do page footer calculations, but it's not easy. It requires some tricks. But you can just put these guys down here.
Again, it's a bug somewhere. Copy, paste. Oh, it worked that time. See? Sometimes it works, sometimes it doesn't. It's really weird. I'm glad that it worked that time, though. We'll stick that there, and I'm going to leave room for a thick line on top of it.
I'm going to take this guy, copy it, click down here, paste. See? Copy, paste. And it's not pasting. Copy, paste. Ooh, it's driving me crazy. Make a new line. Access team, get on this. It's driving me crazy.
Then we'll go to Format, Shape Outline, and we'll make it thicker. There we go. Now, as it is right now, that should be good enough. See? There's your totals.
There's one thing that I like to do, though. I have to do it, but I like to name these guys properly because they come in as Text15, Text16, and so on. So, let's call this ReportPastDue. This one will be ReportDueIn7. ReportDueIn30. And this is just proper database technique, people. Report, and it's just over 30.
But I'll be completely honest, I didn't always use to do this. I only usually really bother naming a text box, or a control in general, if I'm going to refer to it, like if somebody else needs it for its value, which, as you're going to see in a minute, someone will. So that's when I usually bother naming them.
We've got our totals going here for each client. We've got our totals for the report as a whole. Now we need one more over here. This report, or this total, going this way. So you see the total amount of money due to that payee.
Now, this one's actually, in some ways, easier. I am going to slide all of this stuff because you see my report cuts off here. Because I've got to set the eight and a half by eleven, so eight and a half over, just shy of that because I got quarter-inch margins. We're going to take all of this and just slide it a little bit to the left so I got room for one more field in there, which means you got to get smaller, which means you guys got to get bigger. Come a little bit further over there.
Then we're going to copy this. Actually, we don't copy this guy. We're going to copy this guy. We're not going to actually have a number here. You could do a number here in the query. You could do the calculations here in the report or do them in the query. In fact, now that I'm thinking about it, it's usually better to do them in the query.
So, let's put this guy on pause. Let's close this. Let's go back to our payee, or our Payables query, and let's put that calculation in here because we got all the fields in here.
So, over here, this is just going to be, let's zoom in, Shift+F2. I'm going to move this so we can see what's behind it. Total Due is going to be the past due plus due in seven plus due in 30 plus over 30. It's literally that simple.
I like having it here because you can actually sum it up now in the report as well. So, there's our Total Due. This should be this going across. Yep.
Let's clean this up just a touch by taking the payee and moving it over here. And the paid dates, it's always null. You don't even have to see that. You can turn that off because we don't need it to carry through to the report. Looking good.
So, let's close this. I go back to our report in Design view and maximize it. Now we have another field we can work with. I'm just going to copy and paste this guy. Copy and paste this guy. It's really annoying.
We're just shy. Oh. I'm going to slide everybody over one more pixel. These aren't pixels. These are...
Now, this is going to be the total. We'll come into our label at the top. Total due. This guy. Copy, paste. Copy, paste. There we go. Let's slide you over here. This is going to be the sum of Total Due, Payee Total Due. Then copy, paste. You're right there.
What do we call you? Report Sum Of Total Due. ReportTotalDue. Save it. Preview it. There we go. So you totally owe $4,551 to everybody in your database. Intro Need a subtotal for each group and one grand total at the end of your Access report? I'll show you where to put the Sum expressions, how the Group Footer differs from the Report Footer, and how to check the totals in Print Preview. I'm using an accounts payable report, but the same idea works for other grouped reports. For the full database build, see my Access Payables Seminar at https://599cd.com/Payables.
Related Video: https://youtu.be/yKKz9e3nGuE Quiz Q1. Which control should you use to close the Group, Sort, and Total pane without deleting a grouping or sorting level? A. The button that closes the grouping pane B. The X next to the grouping level C. The Delete key D. The report Close button
Q2. What expression should be used in a group footer text box to total the Past Due values for the current group? A. =DSum("PastDue") B. =Sum([PastDue]) C. =[PastDue]+[DueIn7] D. =Count([PastDue])
Q3. What does the Sum function in a group footer total? A. Every record in the database B. Only the records on the current printed page C. The records within that group D. Only the first record in the group
Q4. Why might you set decimal places to zero in a financial report? A. To prevent totals from calculating B. To hide all currency symbols C. To make the report easier to read when pennies are not important D. To convert all amounts to whole dollars in the table
Q5. Where should you place controls that display totals for the entire report? A. Page Header B. Detail section C. Group Header D. Report Footer
Q6. Why is the Report Footer generally preferred over the Page Footer for overall report totals? A. The Report Footer appears only once and can easily total all records B. The Report Footer appears on every page C. The Page Footer cannot contain controls D. The Page Footer only works with text fields
Q7. What is a good reason to give report text boxes meaningful names such as ReportPastDue or ReportTotalDue? A. It changes the stored values in the table B. It makes controls easier to reference later in expressions or code C. It automatically adds the fields to the query D. It prevents users from editing the report
Q8. Where was the Total Due calculation created in this lesson? A. In the table design B. In a VBA module C. In the report's Detail section only D. In the query
Q9. Which expression correctly calculates Total Due for a record? A. [PastDue] + [DueIn7] + [DueIn30] + [Over30] B. Sum([PastDue], [DueIn7], [DueIn30], [Over30]) C. [PastDue] - [DueIn7] - [DueIn30] - [Over30] D. DSum([PastDue]+[DueIn7]+[DueIn30]+[Over30])
Q10. After adding Total Due as a calculated field in the query, how can you create a total for each payee in the report? A. Use =Count([TotalDue]) in the page header B. Use =Sum([TotalDue]) in the payee group footer C. Use =[TotalDue] in the report header D. Use =Average([TotalDue]) in the Detail section
Q11. How can you create an overall total of Total Due for the entire report? A. Place a text box in the Report Footer with =Sum([TotalDue]) B. Place a label in the Detail section with =[TotalDue] C. Place a text box in the Page Header with =Count([TotalDue]) D. Place a line control in the Group Header with =Sum([TotalDue])
Q12. What is the purpose of adding a thick line above report totals? A. To calculate the totals automatically B. To visually separate totals from the report detail C. To force currency formatting D. To create a new group level
Answers: 1-A; 2-B; 3-C; 4-C; 5-D; 6-A; 7-B; 8-D; 9-A; 10-B; 11-A; 12-B
DISCLAIMER: Quiz questions are AI generated. If you find any that are wrong, don't make sense, or aren't related to the video topic at hand, then please post a comment and let me know. Thanks. Summary Today's video from Access Learning Zone continues building our Accounts Payable report by adding subtotal and grand total calculations, formatting the results as currency, and adding a Total Due column for each payee.
Before making these changes, I want to point out a small but important issue with the Group, Sort, and Total pane in Access. The button used to close the pane looks very similar to the button that deletes a grouping or sorting level. Be careful to use the button that closes the pane rather than accidentally deleting one of your grouping levels.
I begin by adding a text box to the Payee footer section for the Past Due subtotal. The control source uses the regular Sum function to add all Past Due values within the current payee group. There is no need to use DSum here because a group footer automatically works with the records in that group.
I name this subtotal control PayeePastDue so that its purpose is clear. Although Access assigns default names such as Text15 or Text16, it is good database practice to use meaningful names, especially if I may need to refer to those controls later.
After saving and previewing the report, I confirm that the subtotal is correct. I then format the amount as Currency.
For this type of report, I normally set decimal places to zero. Unless pennies are especially important for your situation, displaying .00 on every amount tends to make the report harder to read. I select the applicable currency controls and set their Decimal Places property to zero.
Next, I create similar subtotal controls in the Payee footer for Due In 7, Due In 30, and Over 30. Each control uses the Sum function for its respective field, and I give them meaningful names:
PayeeDueIn7 PayeeDueIn30 PayeeOver30
I also bold these footer totals so they stand out from the individual detail records.
If you want a visual separator between the detail records and the subtotal area, you can add a Line control in Report Design view. This is purely a formatting choice, but it can make the report easier to read.
Now that the payee-level totals are complete, I add grand totals for the entire report. These totals belong in the Report Footer, not the Page Footer. A Report Footer appears once at the end of the entire report, making it ideal for report-wide totals. Page Footer calculations are possible, but they require additional techniques and are not as straightforward.
I add a line above the grand totals and increase its thickness using the Shape Outline settings. This gives the total section a clean separation from the rest of the report.
In the Report Footer, I add totals for Past Due, Due In 7, Due In 30, and Over 30. Each one uses the Sum function, just as the group footer controls do, except these controls summarize every record in the report.
I name the report-level controls as follows:
ReportPastDue ReportDueIn7 ReportDueIn30 ReportOver30
Giving controls descriptive names is not always necessary when building a simple report, but it becomes important whenever another control, expression, macro, or VBA procedure needs to reference them.
Next, I add a Total Due amount for each payee. This represents the total amount owed to that payee across all aging categories: Past Due, Due In 7, Due In 30, and Over 30.
Although it would be possible to calculate that value directly in the report, I prefer to create the calculation in the query. Since the query already contains all four aging fields, it is the best place to calculate the overall total.
In the Payables query, I add a calculated field named Total Due. This field adds together the Past Due, Due In 7, Due In 30, and Over 30 values. Once the calculation is in the query, it becomes available throughout the report and can also be totaled in the Report Footer.
While cleaning up the query, I move fields into a more logical order and hide any fields that are not needed in the report. For example, if a field such as Paid Date is always Null for the records in this report, there is no reason to include it in the report's record source output.
Back in the report design, I make room for the new Total Due column. Because the report is constrained by the printable width of the page, I shift and resize the existing columns slightly to fit the new field within the page margins.
I then add the Total Due field to the detail section and create a column label for it. In the Payee footer, I add a subtotal for Total Due using the Sum function and name it PayeeTotalDue.
Finally, I add a Report Footer total for Total Due and name it ReportTotalDue. This gives me the complete amount owed across all payees in the database.
At this point, the report includes individual invoice amounts, aging categories, payee subtotals for each category, a Total Due amount for each payee, and grand totals for the entire report. The final Report Footer Total Due shows the total outstanding balance owed to all payees.
You can find a complete video tutorial with step-by-step instructions on everything discussed here on my website at the link below. Live long and prosper, my friends. Topic List Adding group footer totals to an Access report Using Sum expressions for grouped report totals Formatting report totals as currency Setting report decimal places to zero Adding report footer grand totals Naming report total controls Calculating a Total Due field in a query Adding payee total due to an Access report Article To add totals to an Access report, you can use calculated text boxes in group footers and the report footer. Group footer totals summarize records within each group, while report footer totals summarize every record in the report.
First, make sure the Group, Sort, and Total pane is closed only when you are finished using it. Be careful with the small close controls in that area. One closes the entire grouping pane, while another may remove an individual grouping or sorting level.
To create a total for a payee group, add a text box to the Payee Footer section of the report. Set the text box Control Source to a Sum expression based on the field you want to total. For example, if you have a field named PastDue, set the Control Source to:
=Sum([PastDue])
This totals all PastDue values for the current payee group. You can add similar controls for the DueIn7, DueIn30, and Over30 fields. Give each total a meaningful name, such as PayeePastDue, PayeeDueIn7, PayeeDueIn30, and PayeeOver30. Naming controls is especially helpful when you later need to refer to their values in another calculation.
Format the total controls as Currency. You may also want to set Decimal Places to 0 if cents are not important for this report. This makes the report easier to scan by removing repeated .00 values. You can also bold the group footer totals so they stand out from the individual detail records.
If you want a visual separator between the detail records and the subtotal, add a line control above the group footer totals. A simple horizontal line helps make each group easier to read.
Next, add grand totals for the entire report. These belong in the Report Footer, not the Page Footer. The Report Footer prints once, after all report records have been processed, so it is the appropriate place for overall totals.
Add text boxes to the Report Footer and use the same type of Sum expressions:
=Sum([PastDue])
=Sum([DueIn7])
=Sum([DueIn30])
=Sum([Over30])
These controls provide totals for every record in the report. Name them clearly, such as ReportPastDue, ReportDueIn7, ReportDueIn30, and ReportOver30. Add a thicker horizontal line above these controls to make the grand total area visually distinct.
You may notice that copying and pasting multiple controls in report Design View can behave inconsistently. If Access does not paste a group of selected controls, copy and paste them one at a time. This is slower, but it avoids losing time trying to make a multi-control paste work.
You can also add a total for each individual record across several aging columns. For example, if each record has PastDue, DueIn7, DueIn30, and Over30 amounts, create a calculated field in the report's record source query named TotalDue. Its calculation should add those four fields together. In plain language, TotalDue should equal PastDue plus DueIn7 plus DueIn30 plus Over30.
Creating TotalDue in the query is often preferable to calculating it only in the report because the value becomes available throughout the report. You can display it in the detail section, subtotal it in the Payee Footer, and total it again in the Report Footer.
After adding TotalDue to the query, reopen the report in Design View and add the TotalDue field to the detail section. Adjust the widths and positions of the existing controls as needed so the new column fits within the printable report width. Update the column label to Total Due.
Then add a Payee Footer subtotal using:
=Sum([TotalDue])
Name this control something like PayeeTotalDue. Finally, add a Report Footer grand total using:
=Sum([TotalDue])
Name this control ReportTotalDue.
At that point, the report provides three useful levels of information. Each detail row shows what is owed in each aging category and the total due for that record. Each payee group shows subtotals for that payee. The Report Footer shows the total amount owed across everyone included in the report. Primary Topics
Access report group footers, report footer grand totals, Sum aggregate function, calculated query fields, currency formatting, decimal-place formatting, report control naming, report layout adjustments
Secondary Topics
grouping pane close versus delete controls, adding separator lines, bold subtotal formatting, report width and margins, Access copy/paste control behavior
|