Let’s say i have a 100 command buttons and images in an access form i need to deal with them as groups for example in English : Group1 includes commandbutton1 To Commandbutton10 and Image1 To Image10
me.group1.visible = false
The result would be hide buttons from 1 To 10 and hide images from 1 to 10 I need to declare the groups names and each group includes which command buttons and images then deal with them as i mentioned above how can i do that ? thanks in advance
One thing that you could look at is using the .Tag
property of the controls. You could either just have a single piece of text and check for equality, or else you could have several pieces of text and check if a piece of text exists (which allows you to have controls being members of several groups). A basic example is:
Private Sub cmdVisible_Click()
On Error GoTo E_Handle
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "Group1" Then
ctl.Visible = Not ctl.Visible
End If
Next ctl
sExit:
On Error Resume Next
Exit Sub
E_Handle:
MsgBox Err.Description & vbCrLf & vbCrLf & "frmVisible!cmdVisible_Click", vbOKOnly + vbCritical, "Error: " & Err.Number
Resume sExit
End Sub
Regards,