Here is a quick and dirty way to do this:
I created a form with 5 check boxes, and one text box. I let Access name them, hence Check0, Check2, etc.
I put this code on the Form's On Current event, and on each of the check boxes After Update events.
When I check or uncheck a box, the text box immediately shows the tally:
'==========
Dim chk0 As Long
Dim chk2 As Long
Dim chk4 As Long
Dim chk6 As Long
Dim chk8 As Long
Dim lgText As Long
If Check0 = -1 Then
chk0 = 1
Else: chk0 = 0
End If
If Check2 = -1 Then
chk2 = 1
Else: chk2 = 0
End If
If Check4 = -1 Then
chk4 = 1
Else: chk4 = 0
End If
If Check6 = -1 Then
chk6 = 1
Else: chk6 = 0
End If
If Check8 = -1 Then
chk8 = 1
Else: chk8 = 0
End If
lgText = chk0 + chk2 + chk4 + chk6 + chk8
Me.Text10 = lgText
'==========
HTH
mmcdonal
|