Control Arrays

  • Thread starter Thread starter Charles
  • Start date Start date
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
 
Unfortunately, this is one feature you don't have.

If you just need to work with a group of controls and NOT share the save
event code, the you can do several things.

Use a naming convention for the controls. So, name controls Pro1, Pro2, Pro3
etc.

Then, to set all of our 12 controls in the group to blank (ie: control
Pro1...Pro12)
you can use:

for i = 1 to 12

me("pro" & i) = null

next i

So, just be aware that you CAN stuff the name of a control into a variable,
and use that.

strC = "pro1"
msgbox "the value of " & strC & " is = " & me(strC)

Another trick and it works well is simply to use the "tag" property of each
control. This is good when you have a group of controls on a form, but don't
have, or want to follow a numbering scheme. You simply make up a group name,
and set the tag propriety of each control. You get:

for each vContorl in me.Controls

if vContorl.Tag = "MyGroup1" then
vContorl = null
end if
next vContorl

And, sometimes, people actually in the forms on-load event will create a
collection based on the tag.

Also, we don't have the "clone" ability of control arrays either. However,
for repeating controls, usually a sub-form eliminates the need of the clone
method.

Last, but not least, you can't share a common event code for the group, but
you certainly can place a function name in the approach event. So, if I
highlight and select 10 text boxes on the screen, I can then type in the
name of the function for on-click and it will apply to ALL 10 controls.

Not knowing what you are trying accomplish, it is tough to give the best
alternative in ms-access. However, I rarely, if at all miss control arrays,
as there is plenty of work arounds. If none of the above suggestions seems
to be a solution, then post your actual problem, and not just the request
for a control array...you will likely get a some good ideas here! There is
usually a good workable solution here
 
Hi Albert,
And, sometimes, people actually in the forms on-load event will
create a collection based on the tag.

I wrote a collection class that does all of this - it also allows you to set
a group properties which are then applied to each member of the group. It's
the ControlGroups sample on
www.daiglenet.com/msaccess.htm

Anyone who is interested in working with a collection of controls can get
some ideas from this sample.
 
Back
Top