A
alex
Loop through checkboxes
Hi,
I’m attempting to loop through a series of checkboxes (not part of
option group) to see if ANY has been checked (a user can check 1 or
all of them). If so, I want to enable a series of textboxes.
Here’s the code:
For Each ctl In Me.Controls
If ctl.Tag = "Grouping1" Then 'first group
If ctl.Value = True Then
'would like the code below to read
'if ctl.tag = "Grouping2" then enable
Me.comSubject.Enabled = True 'one of the textboxes in
group 2
Debug.Print (ctl.Name)
Else
Me.comSubject.Enabled = False
End If
End If
Next ctl
The code seems to work, but somehow gets confused (sometimes the
textbox will be enabled and sometimes not, depending on the order in
which a check box has a value??).
Also, when the user checks a box, this code is in the form’s on
current event, so it won’t immediately fire. If I add a call to the
form’s after update event will it fire then (after a box was checked
or unchecked)? Or will I have to add code to each checkbox’s after
update event?
Thanks,
alex
Hi,
I’m attempting to loop through a series of checkboxes (not part of
option group) to see if ANY has been checked (a user can check 1 or
all of them). If so, I want to enable a series of textboxes.
Here’s the code:
For Each ctl In Me.Controls
If ctl.Tag = "Grouping1" Then 'first group
If ctl.Value = True Then
'would like the code below to read
'if ctl.tag = "Grouping2" then enable
Me.comSubject.Enabled = True 'one of the textboxes in
group 2
Debug.Print (ctl.Name)
Else
Me.comSubject.Enabled = False
End If
End If
Next ctl
The code seems to work, but somehow gets confused (sometimes the
textbox will be enabled and sometimes not, depending on the order in
which a check box has a value??).
Also, when the user checks a box, this code is in the form’s on
current event, so it won’t immediately fire. If I add a call to the
form’s after update event will it fire then (after a box was checked
or unchecked)? Or will I have to add code to each checkbox’s after
update event?
Thanks,
alex