NigelShaw
03-09-2008, 08:10 AM
Hi,
can form objects be grouped? i currently have numerous buttons on a form that are shown according to a button selection. my current code makes all buttons visible / invisible singularly but i wiondered if they could be grouped/ named and the get the code to make the group visible / invisible?
many thanks,
NS
pbaldy
03-09-2008, 09:14 AM
Sounds like you are using a loop to go through the buttons. If so, one way to do what you're asking is to use the Tag property of the controls and test that:
If ctl.Tag = "Group1" Then
...
NigelShaw
03-09-2008, 09:30 AM
Hi PBaldy
i am no using a loop. i have the code as
me![Form]![button1].visible = false
me![Form]![button2].visible = false
and so on. the visible becomes true depending on what section is selected on the main form.
i wondered if they could be grouped like
group 1 = [button1] & [button2]
group 2 = [button3] & [button4]
then depending on the main selection, ther groups would be toggled.
group1.visible = false
group2.visible = true
thanks,
NS
WayneRyan
03-09-2008, 10:31 AM
Nigel,
Form objects can't be grouped. There also can not be arrays of controls.
But, if you name them systematically, you can achieve a similar result by
referencing them:
Dim i As Integer
For i = 1 to intGroup1Length
Me.Controls("txtGroup1Field" & CStr(i)).Visible = False
Next i
Wayne
NigelShaw
03-10-2008, 02:59 AM
Hi,
i ended up creating my buttons in visual groups
( so they are visually grouped )
and placing them on top of each other and having a code to make them all visible.false
then when certain buttons are pressed to view certain areas, the relevant buttons are made visible and all others are made visible.false.
though an answer to another topic of mine has shown another way by placing the buttons on their own form and placing a small subform where i would like my buttons. then, the selection buttons can be pressed and change the subform sourceobject to the relevant button form but i havent done that yet.
regs,
NS