Object Address with variable

G

Guest

I am sure that this is one of those questions that have been asked 100K
times, but I still could use a little wisdom from this group.

I am trying to access several text boxes on a form from a vb procedure and
all the text boxes have names set up for a nice FOR-Next loop.. Text201,
Text202, Text203, etc. How can I get the string “strText†into the address
for the form text box. The essence of what I am trying to do is shown here.


strVariable = TextArray(i) ‘runs through an array with For-Next Loop
strText = “Text2†& strVariable
Me![‘strText’].Backcolor = 0


Thanks in advance for your help.
 
D

Dirk Goldgar

MechEngr said:
I am sure that this is one of those questions that have been asked
100K times, but I still could use a little wisdom from this group.

I am trying to access several text boxes on a form from a vb
procedure and all the text boxes have names set up for a nice
FOR-Next loop.. Text201, Text202, Text203, etc. How can I get the
string "strText" into the address for the form text box. The essence
of what I am trying to do is shown here.


strVariable = TextArray(i) 'runs through an array with For-Next Loop
strText = "Text2" & strVariable
Me!['strText'].Backcolor = 0


Thanks in advance for your help.

Me.Controls(strText).BackColor = 0
 
G

Guest

:) That was too easy.... Now why doesn’t my vb book or the help screen
explain it that way. Thanks very much.

Ya know… I am really starting to like this discussion group.

Cheers

MechEng


Dirk Goldgar said:
MechEngr said:
I am sure that this is one of those questions that have been asked
100K times, but I still could use a little wisdom from this group.

I am trying to access several text boxes on a form from a vb
procedure and all the text boxes have names set up for a nice
FOR-Next loop.. Text201, Text202, Text203, etc. How can I get the
string "strText" into the address for the form text box. The essence
of what I am trying to do is shown here.


strVariable = TextArray(i) 'runs through an array with For-Next Loop
strText = "Text2" & strVariable
Me!['strText'].Backcolor = 0


Thanks in advance for your help.

Me.Controls(strText).BackColor = 0


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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