Text box name & variables

G

Greg Franke

I have a form with several text boxes that I need to update values in.
Example

form_form1.Text_1_A
form_form1.Text_1_B
form_form1.Text_1_C

form_form1.Text_2_A
form_form1.Text_2_B
form_form1.Text_2_C

etc.
What I want to do is be able to use a variable inplace of a hardcoded number
like this.

form_form1.Text_(variable)_A
form_form1.Text_(variable)_B
form_form1.Text_(variable)_C

any ideas?

Thanks
 
G

Graham Mandeno

Hi Greg

You can refer to the member of any collection using a string in parentheses,
and the string can be an expression.

So you can use this syntax:

Form_form1("Text_" & intNumber & "_" & strLetter)
 
G

Greg Franke

Thanks Graham!

Took me a few tries to get it right but it is working great!

Thanks again for your help!

Greg

Graham Mandeno said:
Hi Greg

You can refer to the member of any collection using a string in parentheses,
and the string can be an expression.

So you can use this syntax:

Form_form1("Text_" & intNumber & "_" & strLetter)
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Greg Franke said:
I have a form with several text boxes that I need to update values in.
Example

form_form1.Text_1_A
form_form1.Text_1_B
form_form1.Text_1_C

form_form1.Text_2_A
form_form1.Text_2_B
form_form1.Text_2_C

etc.
What I want to do is be able to use a variable inplace of a hardcoded number
like this.

form_form1.Text_(variable)_A
form_form1.Text_(variable)_B
form_form1.Text_(variable)_C

any ideas?

Thanks
 

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