Suppressing a MsgBox in a specific situation

M

Marcel Stoop

Hi

I have created a Textbox.
In some cases I give a MsgBox out when an user leaves this Textbox.
Event: either by "LostFocus" or "OnExit".
But, if user leaves this textbox by clicking on Command Button "Cancel" I
do not want this MsgBox to be generated.

Is there a way of doing this.
I have tried playing around with "If... Then" functions on "LostFocus" and
"OnExit" events on "txtTextbox" and also with "GotFocus" or "OnEnter" events
on cmdCancel.

So far I have not been successful.
 
D

Douglas J. Steele

Unfortunately, since in order to click on the Cancel button, the user must
leave the textbox, I don't think there's anyway of doing what you want.
 
A

Arvin Meyer [MVP]

You can try using the form's Before Update event instead of the On Exit or
Lost Focus event of the text box, to look at the text box and make the
decision. Unfortunately both of your event will fire before the Click eevent
of the command button.

To use the BeforeUpdate event, set a flag ( a form level variable declared
outside the procedure) when the command button is clicked, then check the
flag in the form's BeforeUpdate event before throwing up your MsgBox.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Top