ViPeRSe7eN
Programmer
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?
Ive got a hack going at the moment for the labels and combo boxes which basically consists of :
dim labelarray(0 to 40) as label
labelarray(0) = label1
labelarray(1) = label2
labelarray(2) = label3
labelarray(3) = label4
labelarray(4) = label5
labelarray(5) = label6
.... and so on
but i cant do this for the command button, im working on a hack for it now (just 1 line of code in each button that passes a number to another sub)
private sub cmdclick(clickindex)
' do stuff
end sub
private sub cmd1_click()
cmdclick(1)
end sub
private sub cmd2_click()
cmdclick(2)
end sub
... and so on
but this is all messy, and makes it hard to make changes later, there has to be a better way.
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?
Ive got a hack going at the moment for the labels and combo boxes which basically consists of :
dim labelarray(0 to 40) as label
labelarray(0) = label1
labelarray(1) = label2
labelarray(2) = label3
labelarray(3) = label4
labelarray(4) = label5
labelarray(5) = label6
.... and so on
but i cant do this for the command button, im working on a hack for it now (just 1 line of code in each button that passes a number to another sub)
private sub cmdclick(clickindex)
' do stuff
end sub
private sub cmd1_click()
cmdclick(1)
end sub
private sub cmd2_click()
cmdclick(2)
end sub
... and so on
but this is all messy, and makes it hard to make changes later, there has to be a better way.