What's the difference between Exit and Lost focus?

T

Tony Williams

Could someone explain the significant difference between On Exit and
LostFocus of a form control? If I want something to happen when the user
leaves a control which one should I use?
TIA
Tony Williams
 
K

Ken Snell

They differ in terms of when they occur. Exit occurs before LostFocus.

They differ in the respect that the Exit event can be canceled, LostFocus
cannot.

So, which one you use depends somewhat on what you want to do in that event.
If you want to stop the user from leaving the control if something isn't
right, then you'd probably use Exit (or BeforeUpdate if the validation
involves an entry made in that control by the user). If you want to lock
that control after the user leaves it, you'd use the LostFocus (can't lock a
control while it still has the focus).

And so on.
 
G

Gerald Stanley

Exit has the ability to cancel the change of focus,
LostFocus does not.

If your code does not influence the change of focus, then
place it in the LostFocus eventhandler

Hope This Helps
Gerald Stanley MCSD
 
Top