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

easy way to reference a Control

Status
Not open for further replies.

perfectchaoss

Programmer
Nov 6, 2002
44
US
Hi,
I am working on a form with multiple input fields, every time I want to set a

variable = txtMyTextBox

I have to first

Me!txtMyTextBox.setfocus

Or else i get the message: "you can't reference a property or method for a control unless the control has focus"

It works but is is kind of annoying doing it for every time I want to get a value or display a calculated field. Does anyone know an easier way to do this or another work around? Or is Settingfocus for each text box the only way?
It is also causing problems when I want to set a hidden field equal to a value.
thanks,

JF
 
Something is terribly wrong here.
You stated: variable = txtMyTextBox

You should be using the format me.txtMyTextBox and you didn't in this example. This may be a typo I don't know.

Variable = me.txtMyTextBox is perfectly acceptable without having to set the focus to the control first. Give us a little bit more information so that we may try to help figure this out. This makes no sense whatsoever. Bob Scriver
 
Try this:

Variable=mytextbox.value

Actually, you may be able to leave the .value off, since that's the default property.

I had the same problem a couple of months ago, asked the same question, and got that answer. I don't remember who gave me the answer, but if I did, I'd thank them again!
 
OK thanks guys, the problem was this:
I had
Variable = me.txtMyTextBox.text

Variable = me.txtMyTextBox

works fine

thank you

JF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top