Sum table fields

P

PRodgers4284

I want to sum fields within a table if they equal certain values. I have a
fields in a table called "Action1", "Action2", "Action3" and i want to sum
these fields if the equal certain values, "rub" and "wash".

I have made an attempt at writing a function for this:

=Sum(IIf(EqualTo([Action1]) & ([Action2]) & ([Action1]) , “rubâ€, "wash,1,0))

Can anyone help
 
K

karl dewey

Try this ---
=IIf([Action1] =“rub†OR [Action1] = "wash", 1, 0) + IIf([Action2] =“rub†OR
[Action2] = "wash", 1, 0) + IIf([Action3] =“rub†OR [Action3] = "wash", 1, 0)
 
P

PRodgers4284

karl said:
Try this ---
=IIf([Action1] =“rub†OR [Action1] = "wash", 1, 0) + IIf([Action2] =“rub†OR
[Action2] = "wash", 1, 0) + IIf([Action3] =“rub†OR [Action3] = "wash", 1, 0)
I want to sum fields within a table if they equal certain values. I have a
fields in a table called "Action1", "Action2", "Action3" and i want to sum
[quoted text clipped - 5 lines]
Can anyone help

Hey thanks for that, that works fine. I have added that to the control source
option a textbox called "Action". Is there anyway i can add the value output
in the "Action" textbox to my table without adding a command button and
inserting the value?
 
K

karl dewey

It is poor practice to put calculated values in a table as when the input
data changes the calculation is no longer correct.

You would need an update query.

--
KARL DEWEY
Build a little - Test a little


PRodgers4284 said:
karl said:
Try this ---
=IIf([Action1] =“rub†OR [Action1] = "wash", 1, 0) + IIf([Action2] =“rub†OR
[Action2] = "wash", 1, 0) + IIf([Action3] =“rub†OR [Action3] = "wash", 1, 0)
I want to sum fields within a table if they equal certain values. I have a
fields in a table called "Action1", "Action2", "Action3" and i want to sum
[quoted text clipped - 5 lines]
Can anyone help

Hey thanks for that, that works fine. I have added that to the control source
option a textbox called "Action". Is there anyway i can add the value output
in the "Action" textbox to my table without adding a command button and
inserting the value?
 
P

PRodgers4284

karl said:
It is poor practice to put calculated values in a table as when the input
data changes the calculation is no longer correct.

You would need an update query.
Try this ---
=IIf([Action1] =“rub†OR [Action1] = "wash", 1, 0) + IIf([Action2] =“rub†OR
[quoted text clipped - 10 lines]
in the "Action" textbox to my table without adding a command button and
inserting the value?

Can you help me with the update query?
 
K

karl dewey

Backup your database first. Backup your database first.

Create a select query then click on the Update icon. Enter the formula in
the 'Update To' row of the design view grid under the field you want to
update.

Remember there is no going back to orignal data without the backup.

--
KARL DEWEY
Build a little - Test a little


PRodgers4284 said:
karl said:
It is poor practice to put calculated values in a table as when the input
data changes the calculation is no longer correct.

You would need an update query.
Try this ---
=IIf([Action1] =“rub†OR [Action1] = "wash", 1, 0) + IIf([Action2] =“rub†OR
[quoted text clipped - 10 lines]
in the "Action" textbox to my table without adding a command button and
inserting the value?

Can you help me with the update query?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top