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

Lost Focus

Status
Not open for further replies.

Renebear

Programmer
Mar 25, 2003
8
US
I have an acct# field on screen that checks & then reads the row from a customer.dbf using this acct# on lost focus event. I also have an Add button that enables the user to add new customer. The Acct# is keep in a Control record. When I click on the Add button, somehow the lost focus event happens and gives me an error of Acct# is missing. Can anyone help me on how to suspend the lost focus event whenever I clicked on the add button. I will appreciate any thoughts. Thanks.
 
I assume you have the code to lookup and fetch the record in the account number LostFocus event, correct?

If that's the case,
do this in the LostFocus method:

If empty(this.value)
return
endif

The rest of the code here...


Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
The code executes as it should because the focus has changed from the text field to the ADD-Button, and this causes the text field to lose focus.

Option 1.
You could look at moving the code from the lost focus to another method, such as the interactiveChange event and that may help. This event, however, will fire each time a key is pressed so you need to consider that.

Option 2.
Another option, is to add a property on your form called "skipLostFocusCheck" and set it to .F. On the ADD-Button, add the following code in the mouseEnter Event.

Thisform.skipLostFocusCheck = .T.

In the mouseLeave event add the following code:
Thisform.skipLostFocusCheck = .F.

Modify your lost focus event on the field so it has the following:

IF Thisform.skipLostFocusCheck = .T.
RETURN
ENDIF
* Your code below






Jim Osieczonek
Delta Business Group, LLC
 
Hello Renebear.

>>I have an acct# field on screen that checks & then reads the row from a customer.dbf using this acct# on lost focus event. I also have an Add button that enables the user to add new customer. The Acct# is keep in a Control record. When I click on the Add button, somehow the lost focus event happens and gives me an error of Acct# is missing. Can anyone help me on how to suspend the lost focus event whenever I clicked on the add button. I will appreciate any thoughts. Thanks. <<

You can wrap your code like this:

Code:
lcFldState = NVL( GETFLDSTATE( -1, 'MyAlias' ), '' )
IF 3 $ lcFldState OR 4 $ lcFldState
  *** The user is adding a new record
ELSE
  *** Read customer data
ENDIF



Marcia G. Akins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top