How to make objects groups (1 Viewer)

VBANewBie :)

Member
Local time
Today, 22:00
Joined
Apr 14, 2021
Messages
88
Hi guys , 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

Code:
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.
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:00
Joined
Sep 21, 2011
Messages
14,047
You could use the Tag property to group them?
 

VBANewBie :)

Member
Local time
Today, 22:00
Joined
Apr 14, 2021
Messages
88
You could use the Tag property to group them?
Thanks for reply , I don’t want to use that because my design have a side menus so i need to keep the design as it is , i need a flexible way to deal with them.
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:00
Joined
Sep 21, 2011
Messages
14,047
Thanks for reply , I don’t want to use that because my design have a side menus so i need to keep the design as it is , i need a flexible way to deal with them.
I have no clue as to why a Tag property would affect whatever that is meant to be, so hopefully someone will offer something else.?
 

VBANewBie :)

Member
Local time
Today, 22:00
Joined
Apr 14, 2021
Messages
88
I have no clue as to why a Tag property would affect whatever that is meant to be, so hopefully someone will offer something else.?
Sorry i got your reply wrong i thought you meant tap groups, You are right the tag property could be the way but i haven’t used it before
 

moke123

AWF VIP
Local time
Today, 16:00
Joined
Jan 11, 2013
Messages
3,852
The tag property is probably the way to go. In fact you can have objects that can belong to more than one group if needed. You just use InStr() instead of = when you test the tag property.

Code:
If InStr(1, ctl.Tag, "Group1") Then . . .
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:00
Joined
May 21, 2018
Messages
8,463
In conjunction with the Tag property you can also put them into collections. Make them form level variables.

private group1 as new collection
private group2 as new collection
private groupN as new collection

Then in the on load event you can loop all the controls and put them in the individual group collections. Then from that point on you can call code to loop by group instead to looping all the controls and checking the tag. This may simplify some of the coding.
 

VBANewBie :)

Member
Local time
Today, 22:00
Joined
Apr 14, 2021
Messages
88
In conjunction with the Tag property you can also put them into collections. Make them form level variables.

private group1 as new collection
private group2 as new collection
private groupN as new collection

Then in the on load event you can loop all the controls and put them in the individual group collections. Then from that point on you can call code to loop by group instead to looping all the controls and checking the tag. This may simplify some of the coding.
Thanks good idea
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:00
Joined
Feb 19, 2002
Messages
42,973
Of course, normalizing the table would probably be the best solution.

Another band-aid for a poor design is to use boxes that are the same color as the background. Then you can move them from front to back and vice versa to hide/show the controls beneath them.
 

Users who are viewing this thread

Top Bottom