How to Select all Check Boxes with VBA

  • Thread starter Thread starter wbwillson
  • Start date Start date

Is this post helpful?

  • Yes

    Votes: 0 0.0%
  • No

    Votes: 0 0.0%

  • Total voters
    0
W

wbwillson

Guest
I have a form, and on that form I have 31 Checkboxes. The idea is that the user will check the boxes for the fields he/she would like to see on a report. I'm trying to create an "Ad-Hoc" report system. How can i programmatically determine the value of the checkboxes. I know I can do it the really long way like:

If chkLastName.Value = -1 Then
chkValue = "Last Name"

but since there are so many of them (31) the combinations are huge... Is there a way to determine if none of the values are checked but one or two are?

Sorry, I'm a bit of a newbie to VBA, I appreciate any help. Thanks

Bill
 
ok, u have kicked ur self a bit in the foot on this one but u might be able to sort ur self out.

First. Assuming "First Name" is a field name

Y oh Y oh Y do people put spaces in field names, they are just an unnessasry nussance,:mad: :( :rolleyes:

ok rant over

try this or a vairiation on it

Dim n As Control

For Each n In Controls
If n.ControlType = 106 Then '106 = chkBox
ChkValue = Mid(n.ControlName, 4)
End If
Next

:cool:ShadeZ:cool:
 

Users who are viewing this thread

Back
Top Bottom