Martin Dashper said:
I have several groups of checkboxes on a form and what I want to do is
control each group separately, for example, disable all the checkboxes
in a group at once.
As JohnFol suggested, I use the Tag property for that. For example, I
might have some controls with their tags set to A, and some with their
tags set to B. Then I'd have code like this:
'----- start of code -----
Public Sub EnableControlGroup( _
frm As Access.Form, _
GroupID As String, _
YesOrNo As Boolean)
Dim ctl As Access.Control
For Each ctl in frm.Controls
If ctl.Tag = GroupID Then
ctl.Enabled = YesOrNo
End If
Next ctl
End Sub
'----- end of code -----
That would allow me to write, in code behind a form,
' Enable controls in group B.
EnableFormControls Me, "B", True
Me.SomeControlInB.SetFocus
' Disable controls in group A.
EnableFormControls Me, "A", False
A more elaborate version of the function would allow you to pass the
property you want to set for the group, and its value.