Array of controls

  • Thread starter Thread starter Guest
  • Start date Start date
Not exactly - but there are several ways to work with groups of controls. 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. Here are several methods - if you
need more help post back with a description of what you are trying to
accomplish and I'll try to give you some more specific ideas.

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
 
Back
Top