Control Arrays

C

Charles

I need to create a control array in Access 2002. Can this done and if so
how does one go about it?

Thanks for any help

CL
 
S

Sandra Daigle

There are no control arrays in Access/VBA. 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top