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!

Why Form_LostFocus() does not Work?

Status
Not open for further replies.

cvl75

Programmer
Mar 8, 2002
19
US
Anyones know why a lost focus event does not trigger?

I can't seem to figure out the problem?..

Thank You in Advance
CL
 
If you mean that you do not get Lost_Focus when you switch to another application then that is by design. You get Lost_Focus only within the VB application. Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
If you mean within the VB application then VB Baisc Concepts explains:
"Note A form can receive focus only if it doesn't contain any controls that can receive the focus."

My corollary frim actual test is
"Therefore the form lost_focus will not be fired if the form never had the focus." Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
The event will fire only under certain conditions, mostly when moving to controls on the same form. In the IDE, when stepping through code, you may never see it fire, or it may never fire at all, or fire when you didn't expect it.
If you want a more sure way to validate a control, then use the validation event and make sure all other controls have the property "CauseValidation" set to true. Even then, the cause validation event may not fire, especially when clicking another form or the MDI form menu or tool bar - this is not just by design - but a must. I wouldn't expect, or even want it to be different.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top