Create a Multiple-Criteria Running Total with DSUM in Microsoft Access
Question details
Calculate a transaction running total in Access using payroll date and reference number to determine the order.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Transactions are ordered by payroll date, with the smaller reference number first when dates match.
- Observed behavior
- Each record should show the sum of its transaction amount and all amounts from earlier records in the specified order.
Confirm that tblWageworksTEST contains TxAmt, PayrollDate, and a unique numeric RefNum. The expression below assumes PayrollDate contains dates without time values and all three fields are populated.
Use DSUM with date and reference-number criteria
Use this calculated field to include all earlier dates and, on the current date, records up to the current reference number.
In Access, select Create > Query Design and add tblWageworksTEST. Add PayrollDate, RefNum, and TxAmt to the query grid.
In a blank Field cell, enter: RunningTotal: DSum("[TxAmt]","tblWageworksTEST","[PayrollDate] < #" & Format([PayrollDate],"mm\/dd\/yyyy") & "# OR ([PayrollDate] = #" & Format([PayrollDate],"mm\/dd\/yyyy") & "# AND [RefNum] <= " & [RefNum] & ")")
In the query grid, set Sort to Ascending for PayrollDate and RefNum, with PayrollDate positioned to the left of RefNum. Select Run to review the results.

Review exported Access transactions in WPS Spreadsheets
WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Office format compatibility. Export your Access query to Excel to review the results in WPS Spreadsheets; WPS does not run Access DSUM queries.

Frequently Asked Questions
Why does the DSUM expression use OR between the date conditions?
It includes every record from an earlier payroll date, plus records on the current date whose RefNum is less than or equal to the current RefNum.
Do I need to renumber AutoNumber records after sorting?
No. The expression compares PayrollDate first and uses RefNum only to break ties on the same date. Set both fields to Ascending in Query Design to display that order.
What if PayrollDate contains a time value?
The example assumes date-only values. Remove or account for the time portion before using it; otherwise, equality with the date literal may not match records later in the day.
Why does my total include records hidden by a query filter?
DSUM evaluates tblWageworksTEST independently of the query's filters. Add equivalent conditions to the DSUM criteria if the total should include only the filtered records.




