Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control Array in VBA

Status
Not open for further replies.

ViPeRSe7eN

Programmer
Feb 6, 2003
5
AU
I have a form with 32 labels, 32 combo boxes with slightly different sql querys each, and 32 buttons. I know access doesnt support control arrays, but i cant see any other way of doing it without individually naming each control and pasting in 96 instances of code then changing the names. which i dont wanna do.

cant i create the controls dynamically in vba as an array? i know a decent amount about vb and vba, but have never played with dynamic controls. would this work? and if so how would i do it?
 
Hi,

Not sure about this, I've used control array's in VB in the past and they are essential sometimes.

Have you looked at how frames work in Access? I think you can refer to objects within a frame in the same way.

Not sure - maybe a good pointer.

Regards,

Darrylle "Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
but how would i reference the command button clicks? id still need code in each and every button...
 
Hi,

How would you do this within a control array then?
Look at 'frames' in Access help.

Regards,

Darrylle "Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
in vb you make say 10 controls named command(0) - command (9)
the sub to drive them is command_click

you put your code in there and command.index will be the number of the individual button


with frames i still cant get command_click sort of functionality, ive got a hack going at the moment (making a control array in vba then setting the individual named controls into the array)
 
Vip,

You're making me do your work.

My response was: 'Not sure about this' and 'Have you looked at how frames work?'.

If I find it DOES work - I won't be happy that you couldn't be bothered to research it.

This site is not a 'Solutions' provider it's a 'Problem' solver/pointer.

Regards,

Darrylle "Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Hi ViP,

OK, looks like frames won't do it. Option Groups come close, but then we are talking properties of groups of objects en-bloc as opposed to individual references to each object in the group.

I would suggest you re-post this question (because the numerous posts in here will make people think it's been answered successfully).
I would post it as : "Control arrays in Access? (As in VB)".

Regards,

Darrylle

"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top