View Full Version : Summing values by considering the Yes/No checkboxes.


ia04
08-28-2006, 04:09 AM
Hi,

i have created a table that would calculate the total payments that are being made by a certain contractor. I am assuming that the contractor pays the money in three installments.

In a table I have created three fields which are all checkboxes that would state whether a payment has been made or not, for example, checkbox1 would state whether the first payment has been made. And I also have three other fields that states the amount to be paid on each installment

Now, i want to calculate the total amount that have been payed. For example, lets say that the first installment has been made (i.e the checkbox is checked), then the first payment should be added. And if the second payment has been made it should be added as well, thus finally giving the total amount that has been made.

I know how the logic should look like, but i just don't know the syntax that i should use in the query.

Thanks.

Matt Greatorex
08-28-2006, 05:41 AM
total_amount = 0

If [forms]![form name]!checkbox1 = True then
total_amount = total_amount + [forms]![form name]!amount1
end if

If [forms]![form name]!checkbox2 = True then
total_amount = total_amount + [forms]![form name]!amount2
end if

If [forms]![form name]!checkbox3 = True then
total_amount = total_amount + [forms]![form name]!amount3
end if