Suppressing a MsgBox in a specific situation

  • Thread starter Thread starter Marcel Stoop
  • Start date Start date
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.
 
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top