Two Conflicting Events

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!
 
B

boblarson

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

__________________________________
 
M

Marshall Barton

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,
 

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

Top