Count Check Box results

AN60

Registered User.
Local time
Today, 13:02
Joined
Oct 25, 2003
Messages
283
I need to count the number of "Yes" and also the "No" results in a check box so I can compare yes's to no's.
 
Do you mean count the number of checkboxes checked versus not checked? Use some code like this:
Code:
Dim intTrue as Integer, intTotal as Integer
Dim ctl as Control

For Each ctl In Me.Controls
    If Me.ctl.ControlType=acCheckbox Then
        intTotal=intTotal+1
        If ctl.Value=True Then
            intTrue=intTrue+1
        End If
    End If
Next ctl
You can make this code a function and have it return the intTotal or intTrue values, giving you the total checkbox and the checked checkbox counts, respectively.
 

Users who are viewing this thread

Back
Top Bottom