Check Boxes to add up a sum

Crampton

Registered User.
Local time
Today, 02:39
Joined
Apr 8, 2003
Messages
41
Sorry if this sounds a daft question but i have tried looking everywhere on MS Access Help but with no luck.

Is there a way to have the fields below as checkboxes that when selected add up the sum of only those parts chosen.

Part A = £52.00, Part B = £85.00, Part C = £41.00 etc etc.

Ie - if Part A and C where selected via a check box, another field called Total would return the figure £93.00.

Thanks in advance for your help
 
A checkbox holds a value of -1 for true and 0 for false. How about multiplying the checkbox value by the price, and reversing the sign?

So Total = -(Price A * Checkbox A)-(Price B * Checkbox B)-(Price C * Checkbox C)

(that's not a valid access formula, by the way, just an illustration of the idea)
 
If you have these checkboxes on the form, and the default value set to 0, you could use code to do the calculation. Here is a very simplistic example. I have a form with 1 command button (Command10) and 4 check boxes (Check2, Check4, Check6, Check8). When you select the boxes and click the command button a msgbox appears with the total.(Check2 = 200, Check4 = 300, Check6 = 400, Check8 = 500)

Private Sub Command10_Click()
Dim val As Integer
val = 0
If Me.Check2.Value = True Then
val = val + 200
End If
If Me.Check4.Value = True Then
val = val + 300
End If
If Me.Check6.Value = True Then
val = val + 400
End If
If Me.Check8.Value = True Then
val = val + 500
End If
MsgBox "The total comes to $" & val & " dollars even"

End Sub

If you have many check boxes, you may want to use a different method in the code, such as a case statement or nested ifs.
 
Check Boxes

Thanks Neileg and Jeremie, I have tried both of your suggestions and both work very well. A Great help.

Thanks Again.
 

Users who are viewing this thread

Back
Top Bottom