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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grab value from text box on form into module

Status
Not open for further replies.

Actuary2B

IS-IT--Management
Jan 30, 2007
7
US
Hello all. I have a macro that runs a function in one of my modules that depends on the value of what was typed into a text box on the form.

For example, the form has two controls. The first allows the user to enter, say, a path. c:\

The second control then runs a VBA function that I'd like to use that.

In VBA, how do I link to the text in the text box that is on that form?

Thanks!
 
Dim str as String
str = me.txtbox
...

the value of "str" will be whatever is in the Text Box, "txtbox".
 
Thanks. Being a bit of a Access neophyte, I assume that "me" refers to the open form and "txtbox" is the name of the text box control I gave it?

TIA,...
 
Sorry but it didn't work. I stumbled across the following:

str = forms!Formname!TextBoxName.value

this worked but the

str = me.textboxname

didn't.

Thanks.
 
Sorry about that.

me.textboxname.value will work if you wanted to use something shorter. I'm sure you saw that already anyway.

Happy coding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top