ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Name of Current TextBox on Userform (https://www.excelbanter.com/excel-programming/403194-name-current-textbox-userform.html)

dunnerca

Name of Current TextBox on Userform
 
I have a user form that has a number of text boxes named "T1", "T2", "T3",
etc. I am writing a procedure in which I would like to access the text box
name (since there are different items to put into the text box depending on
the identity of the text box). Specifically, I would like to create a
variable by a command such as

tmp_box="T"&str(box_nbr)

When I then try to use this variable in something like

frm_name.tmp_box.value

It doesn't use the "T1", "T2", etc.


Rick Rothstein \(MVP - VB\)

Name of Current TextBox on Userform
 
Try it this way...

Me.Controls(tmp_box).Text

Rick


"dunnerca" wrote in message
...
I have a user form that has a number of text boxes named "T1", "T2", "T3",
etc. I am writing a procedure in which I would like to access the text
box
name (since there are different items to put into the text box depending
on
the identity of the text box). Specifically, I would like to create a
variable by a command such as

tmp_box="T"&str(box_nbr)

When I then try to use this variable in something like

frm_name.tmp_box.value

It doesn't use the "T1", "T2", etc.



dunnerca

Name of Current TextBox on Userform
 
Great, Rick. Many thanks .... again.

"Rick Rothstein (MVP - VB)" wrote:

Try it this way...

Me.Controls(tmp_box).Text

Rick


"dunnerca" wrote in message
...
I have a user form that has a number of text boxes named "T1", "T2", "T3",
etc. I am writing a procedure in which I would like to access the text
box
name (since there are different items to put into the text box depending
on
the identity of the text box). Specifically, I would like to create a
variable by a command such as

tmp_box="T"&str(box_nbr)

When I then try to use this variable in something like

frm_name.tmp_box.value

It doesn't use the "T1", "T2", etc.





All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com