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

Get value from a text box without setting the focus? 1

Status
Not open for further replies.

GDGarth

Technical User
Aug 5, 2000
412
US
This is something that's bugged me. I frequently use a text or combo box in a form in code, so I want to assign that value to a variable.

The only way I can seem to do it is to do something like this:

Dim HoldText as string
MyText.SetFocus
HoldText=MyText.text

The problem is, sometimes I don't want to set the focus to the box. Is there a way to get the value in Access '97?

I've tried

HoldText=Forms!MyForm.Mytext.text, but it tells me I can't do this unless the control has the focus.

Is there another way?
 
You're using the wrong property. The Text property refers to the text currently being edited while you have the focus. You want the Value property, which refers to the saved text string. (You don't need to type MyText.Value, only MyText, since Value is the default property.)
 
Wow, it works!

I can't believe the answer is that simple! Now I have to go back and change how I've done everything for the last couple of years.

Thanks for the quick response!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top