PDA

View Full Version : UserForm CheckBoxes using variable for name



Len Piwowar
09-16-2006, 11:13 AM
I have a form with 80 check boxes with the names assigned as ChkBx1, Chkbx2, Chkbx3 through Chkbx80. I would like to use a variable for the checkbox name to check the value of the check box. Such as:


For i = 1 to 80
CurrentChkBox = ?ChkBx? & i
CurVal = UserForm.CurrentChkBox
Next


This will not work since CurrentChkBox is a string and not a control. How can I use a variable as a control name?
Thanks in advance

Norie
09-16-2006, 11:41 AM
Len

Use the form's Controls collection.

For i = 1 To 80
CurrentChkBox = ?ChkBx? & i
CurVal = Me.Controls(CurrentChkBox)
Next