Assigning property of a control on a form without having focus

Janos Nagy

New member
Local time
Today, 03:31
Joined
Apr 7, 2011
Messages
1
Is there any chans to be able to assigning value to a property - i.e some string to the 'Text' property - of a control that not having

focus? As far as I can see the control on a form has to have the focus when you assign a value to one of its properties, otherwise error run-time error 2185 "You can 't reference a property or method for a control unless the control has focus" occure. This is a very limiting claim and I wonder if there is some workaround to get rid of this?
 
The Text property is valid only when the control has focus. It is the current text in the control rather then the value which is updated after the control loses focus.

Set the Value property. Note that the Value property is the default so you can just leave it out and refer to it with the just control name.
 
Galaxiom has given you the spot on information. I just wanted to add a little extra information for you. You actually will find that your need to use the .Text property of a control is very rare. In fact, one of the only places you really need to use it is when using the On Change event of the text box itself. And because the On Change of the text box itself means that you are typing, you would just refer to it without having to set focus. But again, that is very rare and so using the default Value property is the way to go in almost all instances.
 

Users who are viewing this thread

Back
Top Bottom