Dynamically Build Object Name

G

Guest

I am attempting to use a variable to help determine the name of a text box,
so that I can then manipulate the object. For example:

Variable1 = 31
me.txt & [variable1] = "Test"


I have a form w/ a series of 56 text boxes, and this seems it would be much
easier than attempting something like a Case statement.

Any assistance is greatly appreciated.

Sharkbyte
 
G

Guest

I'm not quit sure what you are trying to accomplish but you could loop
through the controls on the form and retrieve the name via the control name
property.

Try something like:

dim ctl as control

for each ctl in me.form
debug.print ctl.name
next ctl

Instead of printing it in the immediate window you can decide what to do
with it.

hth
 
J

John W. Vinson

I am attempting to use a variable to help determine the name of a text box,
so that I can then manipulate the object. For example:

Variable1 = 31
me.txt & [variable1] = "Test"


I have a form w/ a series of 56 text boxes, and this seems it would be much
easier than attempting something like a Case statement.

Any assistance is greatly appreciated.

Sharkbyte

Try

Me.Controls("txt" & Variable1)


John W. Vinson [MVP]
 

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