How to get an instant sum (1 Viewer)

ariansman

Registered User.
Local time
Today, 02:11
Joined
Apr 3, 2012
Messages
157
I have the following form based on a table:
Code:
empName             salary            working
jack                     1000              yes/no
Steve                   1500               yes/no
Janet                   200                yes/no
summary:  [number]

fields “empname” and”salary” are locked, but the working is field is able the be switched between “yes” and “No” by the operator by a click.

Is it possible that the "summary" shows the instant sum of salaries of the employs whose working status is “yes”? For example all “working” are yes and summary shows 2700. But the operator clicks on the working status of Steve and changes it to NO, and the summary right away shows 1200.

i am not sure if this is doable on a form or report.
thank you
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 02:11
Joined
Aug 30, 2003
Messages
36,125
In the form or report footer:

=Sum(IIf(Working = True, Salary, 0))
 

ariansman

Registered User.
Local time
Today, 02:11
Joined
Apr 3, 2012
Messages
157
i am havuing the form in data sheet view. in data sheet view there is not a footer.is that right?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 02:11
Joined
Aug 30, 2003
Messages
36,125
That could be; I never use datasheet view.
 

missinglinq

AWF VIP
Local time
Today, 05:11
Joined
Jun 20, 2003
Messages
6,423
You'd have to use the old trick of using a Continuous View Form and tweaking it to look like a Datasheet View Form.

Linq ;0)>
 

MarkK

bit cruncher
Local time
Today, 02:11
Joined
Mar 17, 2004
Messages
8,181
i am havuing the form in data sheet view. in data sheet view there is not a footer.is that right?
If you are in datasheet, and there is no footer, then where, in the description of the form's design you posted above, is the summary?
Mark
 

isladogs

MVP / VIP
Local time
Today, 10:11
Joined
Jan 14, 2017
Messages
18,219
Just in case you're not aware, it is possible to add a totals row to a datasheet - in a table/query or in a form.
See https://www.access-programmers.co.uk/forums/showthread.php?t=300211

However it will total all visible rows so, for your purposes, you would need to use a query as your datasheet source filtered for Working = yes.
OR use code to change the salary to 0 when Working = No.

I'll leave you to decide whether that's flexible enough for your needs
 
Last edited:

Galaxiom

Super Moderator
Staff member
Local time
Today, 19:11
Joined
Jan 20, 2009
Messages
12,852
i am havuing the form in data sheet view. in data sheet view there is not a footer.is that right?

A Datasheet form does have a footer. It just doesn't display. So you can put a textbox in the footer to do the Sum then refer it in the ControlSource of another textbox.

To use this technique, put a the Datasheet form in a subform and display the result in the parent form.

However I generally use Continuous Forms instead.
 

Users who are viewing this thread

Top Bottom