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

In Got Focus Event-err:cant reference property unless contol has focus

Status
Not open for further replies.

PurpleUnicorn

Programmer
Mar 16, 2001
79
0
0
US
I have a search form from which I open a detail form using the search criteria.
If there are records in the detail form, all is well and the form opens - placing my criteria in an unbound textbox.
I have code in the got focus event of the unbound textbox to place the cursor at the end of the string:

if len(me.txtSearch) > 0 then
Me.txtSearch.selstart = len(me.txtSearch)
end if
(this works find if there are records)

If there are no records - an error is generated
"You can't reference a property or method for a control unless the control has the focus."
I am quite confused since this is all happening in the controls Got Focus event.

Any insight will be greatly appreciated.


 
Is your detail form opening if there's no records corresponding to the search criteria?

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Yes, the detail form opens.
The search form is actually a list of item numbers - the user clicks a search button next to the item of interest to check inventory. The item number is the criteria used in the detail form.
If the item does not exist in inventory (thus no records) - the user needs the opportunity modify the search value in the unbound textbox and requery inventory for similar item numbers. This is done in an after_update event on the unbound textbox that resets the filter with the modified criteria.

If I remove the code that sets the cursor position - the form opens and the focus is on the unbound textbox. I simply can not set the cursor position. I am baffled.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top