ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable Reference to a Form Control (https://www.excelbanter.com/excel-programming/315932-variable-reference-form-control.html)

Sharlene England

Variable Reference to a Form Control
 
How do I access my form control, when I don't know the direct name of the
object, but only have it placed in a variable.

I have a form with an object named TEXTBOX3

then I have a variable name MYVAR with a value of TEXTBOX3

if I say TEXTBOX3.value I get the correct result

if I say MYVAR.value then I get an error

How do I refer to TEXTBOX3 using MYVAR?

Thanks.



Doug Glancy

Variable Reference to a Form Control
 
Sharlene,

MyForm.Controls(MYVAR).value

hth,

Doug Glancy

"Sharlene England" wrote in message
...
How do I access my form control, when I don't know the direct name of the
object, but only have it placed in a variable.

I have a form with an object named TEXTBOX3

then I have a variable name MYVAR with a value of TEXTBOX3

if I say TEXTBOX3.value I get the correct result

if I say MYVAR.value then I get an error

How do I refer to TEXTBOX3 using MYVAR?

Thanks.





Sharlene England

Variable Reference to a Form Control
 
Thanks, Doug, that was exactly what I was looking for.




All times are GMT +1. The time now is 10:17 AM.

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