Escape cancels DAO excute command - Prohibit?

E

Ernie Thomason

In Access 2007, if I run the following command
CurrentDb.Execute "qryAppend", dbFailOnError

and press escape while it's running, an error will be raised:
Run-time error '3059':
Operation canceled by user.

The strange thing is that Access doesn't even need to have focus. This is a
problem because my VB process will stop when a user presses the escape key
while working with another application (as Access is running in background).

Has anyone seen this behaivor before, or know how to stop DAO execute
commands from being interrupted from pressing escape?

Thanks,
Ernie
 
B

bcap

This is appalling. I've tested it and you are indeed correct. I even
tested it in Access 2003 to make sure we're not going insane, and as
expected it does *not* happen there.

I can't see any way to prevent this. You can't even trap the Esc key in the
Form_KeyDown event (although even if you could I don't see how it would
help). Looks like wherever we use the Execute method we're gonna have to be
prepared to catch and handle error 3059. It's gonna look just great to
users (not!) when their Access app throws an error because of something they
did in a completely separate application!

My list of issues with A2007 is already very long indeed. This may just be
the final straw that drives me back to A2003.
 
E

Ernie Thomason

Thanks bcap for your confirmation. I agree that it's just too strange, and I
suppose appalling. Ha. It's common for my customers to use Lotus Notes
while my program is running in the background, and 'esc' seems to be a common
key for them hit. They come back to my program to see a message box
"canceled by user". Oh well, at least they wont fire me over this, but still
annoying for all. Thanks again bcap.

One solution might work for some people. Dunno. :

Private Sub ctlTextBox_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
KeyCode = 0
End If
End Sub

The idea here is that if an escape key is pressed with a certain control is
active, the KeyCode is set to 0, which in effect should stop the event from
propegating to other built in event handlers. This didn't work for me as I
don't really have a control active when my code is running. And I don't even
know why it'd work when another application has focus. I just mention it
here because it seemed to help one person out on some other forum.

Until the next Office service pack.... (too optimistic?)
Ernie
 

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