Hi, Just found that I can group objects on a form together. But I could not
see how to refer to the group, once Id grouped the objects together. For
example, rather than specifying the visibility property for each control upon
a button press, I thought Id group all the appropriate controls together and
then set the visibility property for the group as a whole. But I cant see
how to refer to the group object. Any ideas?
Thanks Tim
Unfortunately, grouping doesn't provide this functionality. A common work
around is to group the controls either by using a common prefix for the name
or by using a special keyword in the tag property of each control that is a
member of the group. Using either of these methods you can then loop through
the controls
to do whatever you require.
Method 1
-------------------
dim ctl as control
for each ctl in me.controls
if left(ctl.name,9)="ctlGroupA" then
'do something
endif
next ctl
set ctl=nothing
Method 2
----------------
dim ctl as control
for each ctl in me.controls
if ctl.tag="GroupA" then
'do something
endif
next ctl
set ctl=nothing
Method 3
--------------
This works if you name your controls with a common prefix and a number
(txtGroupA1, txtGroupA2 . . txtGroupA9)
dim i as integer
for i=1 to 9
'do something to the control
debug.print i, me.controls("txtGroupA" & i).value
next i
Method 4
--------------
Take a look at my website for some custom classes that provide methods for
working with groups of controls:
It's the ControlGroups sample on www.daiglenet.com/msaccess.htm

Signature
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
> Hi, Just found that I can group objects on a form together. But I
> could not see how to refer to the group, once Id grouped the objects
[quoted text clipped - 4 lines]
> the group object. Any ideas?
> Thanks Tim
Timboo - 07 Mar 2005 11:07 GMT
Sandra, Thank you, I will give method 2 a go. Tim.
> Unfortunately, grouping doesn't provide this functionality. A common work
> around is to group the controls either by using a common prefix for the name
[quoted text clipped - 48 lines]
> > the group object. Any ideas?
> > Thanks Tim