Check Boxes on Forms

G

Guest

Is there a way to count the number of "yes" selections that are made on one
form. This form contains ~50 survey-type questions regarding
skills/knowledge in a particular category (i.e., one form is "Events
Coordination". "Events Coordination has about 8 subgroups such as
"Websites", "Budget", etc. There are questions under each subgroup such as
under "Websites"...."work with web developers", design webpage", etc.
.....but all of these checkmarks need to be tallied under the main category of
"Events Coordination" and they want the tally to be displayed directly on the
form and the checkmarks are clicked. I know how to =Count of a report but I
am baffled as to how to count these ~50 items immediately onto the form.
Thanx.
 
G

Guest

You can loop through all the controls on your form looking for check boxes.
Use the ABS function so the -1 that represents Checked (True) will be
conterted to 1 to count the number checked. If there are any check boxes on
your form that should not be included, then you will need to add logic to
exclude that check box. The second example shows that.

Include All check boxes

Function CheckTotals() As Long
Dim lngSumTot As Long
Dim ctls As Controls
Dim ctl as Control

For Each ctl In Me.ctls
If ctl.ControlType = acCkeckbox Then
lngSumTot = lngSumTot + ABS(ctl)
End If
Next
Set ctls = Nothing
Set ctl = Nothing
CheckTotals = lngSumTot
End Functioin
------------------------------------------

Exclude A Check Box named chkDummy

Function CheckTotals() As Long
Dim lngSumTot As Long
Dim ctls As Controls
Dim ctl as Control

For Each ctl In Me.ctls
If ctl.ControlType = acCkeckbox And ctl.Name <> "ctlDummy" Then
lngSumTot = lngSumTot + ABS(ctl)
End If
Next
Set ctls = Nothing
Set ctl = Nothing
CheckTotals = lngSumTot
End Functioin
 
G

Guest

Sounds like a nighmare but I will give it a whirl. Thank you for your quick
response.
 
G

Guest

Is there any way to show the value in real time as the checkboxes are being
clicked rather than having to close the form and re-opening it?

Thanx again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top