How to get an instant sum

ariansman

Registered User.
Local time
Today, 07:56
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
 
In the form or report footer:

=Sum(IIf(Working = True, Salary, 0))
 
i am havuing the form in data sheet view. in data sheet view there is not a footer.is that right?
 
That could be; I never use datasheet view.
 
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)>
 
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
 
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:
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

Back
Top Bottom