Two Conflicting Events

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

On an Access form, I have a textbox containing an AfterUpdate event which can
take up to 2 seconds to execute. (I won't get into why the event takes that
long). Also on the form is a close Button which, when clicked, closes the
current form. If the user has focus in the textbox and immediately click the
close Button, I get the following error:
"Error No: 2501, Error Description: The RunCommand action was cancelded."

This error happends because the close button can't run it's command because
the textbox AfterUpdate event is still running.

Is there a way to prevent this? How can I wait until the AfterUpdate event
is done before running the close button's event?

I hope that makes sense.

Thanks!
 
Actually, I would guess that it has to do with whatever you have in that
AfterUpdate event which you don't want to share. So, unfortunately you
aren't probably going to get the answer until you share the code in the
afterupdate event.
--
Bob Larson
Access MVP
Free Tutorials and Samples at http://www.btabdevelopment.com

__________________________________
 
Mike said:
On an Access form, I have a textbox containing an AfterUpdate event which can
take up to 2 seconds to execute. (I won't get into why the event takes that
long). Also on the form is a close Button which, when clicked, closes the
current form. If the user has focus in the textbox and immediately click the
close Button, I get the following error:
"Error No: 2501, Error Description: The RunCommand action was cancelded."

This error happends because the close button can't run it's command because
the textbox AfterUpdate event is still running.

Is there a way to prevent this? How can I wait until the AfterUpdate event
is done before running the close button's event?


Try disabling the command button at the top of the event
procedure and enablibg it at the end,
 
Back
Top