Naming or refering to a box

echorley

Registered User.
Local time
Today, 17:09
Joined
Mar 11, 2003
Messages
131
Can I somehow name a text box by using an array? For example is there a way to name the text box "textbox(1)" and then when I am programming, refer to the text box by

n = 1
Me.textbox(n) = 50

and then the value of textbox(1) will be 50? My experience so far is that names of controls are strings and there is no way to do this. Any suggestions? Thanks.
 
There's almost always a way...

In your case, you're correct that the names of object must be strings. But, they just need to evaluate to strings. It's easier if you name the textboxes textbox1, textbox2, etc..., but you can still use the parentheses:
Me("textbox(" & n & "))" = 50
will set the value of Me(textbox(1)) to 50

If you leave out the parentheses, it gets a bit more readable, like:
Me("textbox" & n) = 50
will set the value of Me("textbox1")=50
 
Yes!

How clever! Thanks.
 
Just some extra information. Each control on a form has an Index value. If you know the objects' index values you can refer to them like this:

Code:
Me(0)
 

Users who are viewing this thread

Back
Top Bottom