Re: Count number of checked boxes on a form
- From: "Todd" <Todd@xxxxxxxxxxxxxxx>
- Date: Mon, 21 Jan 2008 10:51:01 -0600
Great! Thanks!!!
"Klatuu" <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:2C9E7EF7-B28D-4C3B-9FDB-39401ED3C65A@xxxxxxxxxxxxxxxx
Here is a function that will count how many check boxes on your form are
checked.
Private Function CountChecks() As Long
Dim lngX As Long
With Me
For lngx = 0 To .Controls.Count - 1
If .Controls(lngX).ControlType = acCheckBox Then
If .Controls(lngX).Value = True Then
CountChecks = CountChecks + 1
End If
End If
Next lngx
End With
End Sub
--
Dave Hargis, Microsoft Access MVP
"Todd" wrote:
I would like to add a textbox (txtCheckedForms) that shows the number of
checkbox fields are checked on a form. Is there a simple way of doing this?
The only thing I've come up with so far is something like this...
If chkField1 = True then varCheckedForms = varCheckedForms + 1
if chkField2 = True then varCheckedForms = varCheckedForms + 1
....
ifchkField50 = True then varCheckedForms = varCheckedForms + 1
txtCheckedForms = varCheckedForms
The problem is, I have about 50 checkbox fields on my form. That would take
a long time and a lot of space! Also, the fields aren't actually named
chkFields1, 2, etc. They are all very unique. Is there an easier way?
Thanks!!!
.
- References:
- Count number of checked boxes on a form
- From: Todd
- Count number of checked boxes on a form
- Prev by Date: Re: How to return a specific record for editing?
- Next by Date: Re: Dynamic report printing
- Previous by thread: Re: Count number of checked boxes on a form
- Next by thread: Vlookup problem
- Index(es):