Running Sum in Microsoft Access Report
Continuous Sum MS Access Report Detail Lines
Calculate running sum can be accomplished within an Access report using Access Visual Basic. Calculation of running sum is also the starting point for calculating most
statistical measures. Below are the details for implementing a running sum on a report.
15 years ago we were putting Access database on the web using Active Server Page (ASP) programming language for the user interface. See examples of Access on the Internet.
Follow these steps:
Create an unbound field on the report that will hold and display the running sum value.
Create an On Print event procedure in the Detail section of the report.
In the on print event procedure put a global variable after the 'Option Compare Database'. In this example it is called 'gbl_run_sum'.
Add the code in the Detail_Print procedure as show below. Each Sales value will be sumed as the report is created.
Note that you can also calculate running sum using the running sum property of an unbound field in the detailed section of the report. We provide this visual basic example because there may be other calculations what you may want to perform within the report and this example gives you the basic skills needed to do the other calcs. Some examples of
other calculations might be calculation of standard deviation, mean, and other statistics.
You can also try out one of our downloadable
Access examples and see
how a complex sum is calculated in a form. This technique can also be used in
Inventory Database Example
to see the sum calculations.