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!

Can't reference unless focus

Status
Not open for further replies.

DeanReedy

Programmer
Jun 8, 2005
8
US
In code, if I try to get values of items on the form, but I always get the following error: You can't reference a property or method for a control unless the control has focus.

I just want to print the value from two textboxes in a messagebox.

thanks,

Dean
 
Use the .Value property instead of the .Text

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
How are ya DeanReedy . . .

Your apparently trying to access the [blue]text[/blue] property of a control! . . . Such as:
Code:
[blue]   VariableName = Me!ControlName.Text[/blue]
Whenever yo use the [blue]Text[/blue] property . . . [blue]that control has to have the focus![/blue]

Calvin.gif
See Ya! . . . . . .
 
FYI,
Note To set or return a control's Text property, the control must have the focus, or an error occurs. To move the focus to a control, you can use the SetFocus method or GoToControl action.

While the control has the focus, the Text property contains the text data currently in the control; the Value property contains the last saved data for the control. When you move the focus to another control, the control's data is updated, and the Value property is set to this new value. The Text property setting is then unavailable until the control gets the focus again. If you use the Save Record command on the Records menu to save the data in the control without moving the focus, the Text property and Value property settings will be the same.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top