Creating an array of text boxes?

C

craigwharding

How can I do this? I've tried multiple ways and tried looking on the
web but I can't find anything. I want to have an array of text boxes so
I can easily make them visible, invisible and do other controls on them
instead of lots of lines of code to do the same thing.. This is what I
have so far..


Dim arr(10) As TextBox ' before I has this as Object but still didn't
work
Dim formfield As Variant

Set lc_arr(0) = Me.textbox1
For Each formfield In arr
formfield.visible = False
Next


Any help would be awesomely appreciated..

craig.
 
S

Sandra Daigle

Here is an easy way to achieve the desired results. First name your controls
with a common prefix and a number (txtGroupA1, txtGroupA2 . . txtGroupA9).
Then to loop through the controls use code like the following:

dim i as integer
for i=1 to 9
'do something to the control
me.controls("txtGroupA" & i).visible=false
next i

There are other ways to do the same thing. Let me know if this won't work
and we can explore the alternatives.
 

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