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!

Do Not Run LostFocus Code

Status
Not open for further replies.

AngelB

Programmer
Feb 9, 2004
1,477
GB
Hi All,
I have some code in the lost focus event of a text box on my form. If this control has the focus when the user clicks the close button of the form, the code in the lostfocus method is of course executed. I want the code to run if the user leaves the control by tabbing, hitting enter, clicking elsewhere etc. , but not if the user is exiting the form.

Any suggestions?
Most Grateful

Geraint Evans
 
Check the keystroke (in the lost focus event) and simply exit if it is not one of the above (KeyPress).


(you Can NOT not initiate the event routine if it is present. The only soloution will need to be to check the entry for conditions and either proceede or exit).





MichaelRed


 
How are ya Geraint50 . . . . .

In the [blue]Unload[/blue] event of the form, [blue]move the focus to another control[/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
Thanks for the replies guys,

AceMan, surely the LostFocus code from the textbox will still be executed? From the help files:

Order of events for controls on forms

Exit (control) --> LostFocus (control) -->
Unload (form) --> Deactivate (form) --> Close (form)

Thanks

Geraint
 
Geraint50 . . . .

I was thinking of something else. I remember something but can't put my finger onit yet. I have a too large a library to just guess. I'll post back if anything comes to light . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top