Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access Form - running total for records with checked boxes

Posted on 2013-10-25
10
Medium Priority
?
1,464 Views
Last Modified: 2013-10-31
Hi,
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
0
Comment
Question by:damixa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 21
ID: 39601749
Try:

=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
0
 

Author Comment

by:damixa
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
0
 

Author Comment

by:damixa
ID: 39601784
see error
error
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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:
Zero=False=Off
Any other value=True=On
(Oddly I don't see any values in your image that are: Assigned=yes
0
 

Author Comment

by:damixa
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)
0
 
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?

JeffCoachman
0
 
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;

;-)

JeffCoachman
0
 
LVL 74

Accepted Solution

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

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

Author Closing Comment

by:damixa
ID: 39606084
thank
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39615921
;-)
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

661 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