Access Form - running total for records with checked boxes

Posted on 2013-10-25
Last Modified: 2013-10-31
I have hopefully a relatively simple question.
I have a form that displays results from a query in Access.

I created a textbox that totals my "amount" field by placing the formula "=Sum([amount])" for the Control Source.

What I actually need is a running total for the records that are "Assigned"

so to look something like
=Sum([amount]) where [Assigned] = 1

Open in new window

I tried the above formula but it didnt work. Can somebody point me in the right direction

see attached
Form View
Question by:damixa
  • 5
  • 4
LVL 21
ID: 39601749

=Sum(Nz([Assigned],0) = 1, [amount], 0)

Open in new window

If the check box is bound to a Yes/No data type field then use this:

=Sum(Nz([Assigned],0) = True, [amount], 0)

Open in new window

Note: for Yes/no data type fields false = 0 and True = -1

Also see my example:
Batch Printing and Save As PDF
The Selector form counts check boxes plus some other things that might be helpful

Author Comment

ID: 39601775
I'm not sure what I am doing wrong, but it is giving me "The Expression you entered has a function containing the wrong number of arguments

Author Comment

ID: 39601784
see error
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39601818
1. running sums are tricky in forms.
In a report it is easy: Copy the Amount control and set the running sum property to: Over All

2. <where [Assigned] = 1>
In Access a checkbox will return 0 if false, and -1 when true
The good thing here is that the actual rule is:
Any other value=True=On
(Oddly I don't see any values in your image that are: Assigned=yes

Author Comment

ID: 39601841
Well, the reason being is that I only pull fields that are unchecked. Once I check them and save the form, they will not show up again, they are (Assigned)
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39601945
I think you are confusing the term "running sum" with "Sum" (or in your case,: Grand Total).
A running sum will display the cumulative amount for *each record*
A "Sum" (or Grand total) will only display once

So if you were doing this: =sum(Amount), ...then this is a grand total (sum), not a running sum.

So in order to get the sum (total) of only assigned records, use something like this:
=Dsum("amount", YourTableName","Assigned=True")

Is this what you wanted?

LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39601962
FWIW, a true "running sum" of Assigned records, in a form would look like this:
Running sum
The recordsource for the form would be something like this:
SELECT YourTable.RecordID, YourTable.TransDate, YourTable.DrawerID, YourTable.Amount, YourTable.Assigned, DSum("amount","YourTable","RecordID<=" & [RecordID] & " And " & "Assigned=True") AS RunSum FROM YourTable WHERE (((YourTable.Assigned)=True)) ORDER BY YourTable.RecordID;


LVL 74

Accepted Solution

Jeffrey Coachman earned 500 total points
ID: 39602039
sorry my syntax above was missing  character, it should be:

=Dsum("amount", "YourTableName","Assigned=True")

Author Closing Comment

ID: 39606084
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39615921

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to create a form that compares values from a multi-filter query/form. 15 35
Launch app from Access custom ribbon 8 33
DCount Type Mismatch 2 22
Switch 5 15
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question