How do I sum up values only when checked?

S

sophpos04

I have a database where we are selling items for customers. Therefore, when
an item is sold (ie. the check box is "checked"), I want to add the price of
the item to the total amount owed to the customer.

Anyone know a good approach to this?
 
J

John Vinson

I have a database where we are selling items for customers. Therefore, when
an item is sold (ie. the check box is "checked"), I want to add the price of
the item to the total amount owed to the customer.

Anyone know a good approach to this?

One way would be to create a Totals query with a criterion of True on
the "checked" field.

John W. Vinson[MVP]
 
S

sophpos04

Are you suggesting i create another subform? I understand that the criteria
should be yes for the check field, but how do i add up the totals etc...
 
J

John Vinson

Are you suggesting i create another subform? I understand that the criteria
should be yes for the check field, but how do i add up the totals etc...

No. I didn't say anything about Forms; I suggested a Totals Query
against the database. Data is not stored in forms, but in tables.

If you're already displaying the data on a Form you can include a
calculated field in the Query upon which the form is based:

AddThis: IIF([checkbox] = True, [FieldToAdd], 0)

You can then put a textbox on the Form (or Subform) Footer with a
control source

=Sum([AddThis])

to add up only the checked rows.

John W. Vinson[MVP]
 
Top