Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need contents of variable whose name is in another variable

Status
Not open for further replies.

WaltW

MIS
Jun 14, 2000
130
US
I have a situation where I have the name of one variable in a second variable, but I want to look at and use the contents of the first variable. Example:

Code:
dim strVarName as string
strVarName = "txtData"

If txtData has information in it that I want to use, but all I have to go on is the fact that the contents of strVarName is "txtData", how do I use strVarName to get the contents of txtData?

Thanks for any help you can provide!

WaltW
 
It depends on what txtData is and how you're getting to it. If txtData is a control on a form, you can use .Controls(strVarName). If it's a table field, you can use .Fields(strVarName). If it's simply a declared variable, I don't think you can get to it that way.
 
Thanks for the help! In this case txtData was a text box on a form, so the .Controls(strVarName) worked perfectly. So my question is answered and I'm off and running. Thanks again!

WaltW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top