in Access 2007 I have a BIG PROBLEM with Esc key. An error occurs if <Esc> is hit during a code execution:
Run-time error '3059':
Operation canceled by user.
It happens on OpenRecordset and Execute methods.
The problem occured in Access 2007; previous versions work fine, as some say. I've found two discussions about the problem:
The following page points to a (potential?) hotfix for MS Access 2007 SP2:
http://www.errorhelp.com/search/details/101157/run-time-error-3059-operation-canceled-by-user, ie. http://support.microsoft.com/default.aspx?scid=kb;en-us;962214&sd=rss&spid=11265.
Unfortunatelly, the hotfix doesn't install on MS Access 2007 SP2 CZ (Czech). It ends up with an error: "The expected version of the product was not found on the system."
Any help would be appreciated. Thank you very much for your time in advance.
Desperately need a fix from Microsoft.
I don't know about a bug but if you have an error handler for the routine where the problem occurs, you can choose to ignore error # 3059.
On Error Goto ErrorHandler
'Code you want to protect from the error message
On Error Resume Next
'Close any open data objects, etc.
Select Case Err.Number
'Display error message, log the error, etc.
Thank you for posting in our forum.
Does it only happen on OpenRecordset and Execute methods?
Does the issue persist when you don't use the two methods?
First, i advise you checking the connection to your database.
Runtime error 3059 usually occurs when a DLL file is missing, or not registered on your computer. It is a really common problem for windows users which crashes now and then.
1. Since Runtime error 3059 is related to missing DLL files, you can re-register the registry list to fix Runtime error 3059 issue. For example, if you encounter Runtime error 3059 at dll files, to re-register the file, please do this:
(1). Click Start-Run
(2). Type in regsvr32 c:\windows\system32\dllfile
(3). Re-start your computer
If you cannot find the specific file on your computer, you should download it from the Internet and locate it to the right place.
2. To fix Runtime error 3059, you also can try to run free registry scan for your computer. In my opinion, it is the most important step for you to fix Runtime error 3059 and avoid other runtime errors effectively. There are various registry repair tools available on the Internet that scan, analyze, and fix your computer. Besides fixing your Runtime error 3059, these tools will remove any registry errors, invalid shortcuts, duplicate files and repair DLL files. Eventually, your computer will be free from system error messages and sluggish performance. What you need to do is to fix Runtime error 3059 as well as other registry errors to prevent your registry from total corruption.
I hope this will help you resolve the issue.
If you have any other problems or the issue persists, please feel free to let me know.
Macy Dong [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
thank you very much for your input.
"Does it only happen on OpenRecordset and Execute methods?"
I have not tested any other situation, except OpenRecordset and Execute methods. The bug has been discovered by an accident - user hit <Esc> during long lasting procedure.
"Does the issue persist when you don't use the two methods?"
I need to use these methods. I've found out that <Esc> keypress resides in buffer until the code jumps to OpenRecordset or Execute. I tried to put an empty string to keyboard buffer using SendKeys but it didn't help at all. I'd appreciate some code for MS Access 2007 VBA to clear key buffer
The problem doesn't occur when I don't use OpenRecordset / Execute. I've tested on a simple "do-nothing-loop":
Do While True
"First, i advise you checking the connection to your database."
Connection is OK since the code could not run if connection failed.
Unfortunatelly, I don't know which DLLs I might be missing. The <Esc> bug occurs on any computer we tried, even on a clean installation of MS Windows & Office. We tried various versions of Windows, from Windows XP to Windows 7.
I avoid to use 3rd party registry cleaners since I have experienced total crash of the system that happened some time ago when I tried such tool for the first time.
- Edited by Vladimir Cvajniga Wednesday, May 16, 2012 7:23 AM typo
If I understand correctly, then DoEvents will run the keystroke buffer empty. So the error 3059 will occur less frequently.
Currentdb.openrecordset([datasource], [type]) + Escape generates an unhandled error, even if there is an error handler in the sub/function.
(if you set VB editor options -> general -> break on all errors, then it will highlight the .openrecordset line, and execution will not be passed to the error handler.)
But Currentdb.openrecordset(..,..,dbFailOnError) + Escape generates a trappable error, so an error handler will solve the issue. Works for me:
(Ms Access 2007 prof)
on error goto err:** Edit: Do not place Doevents in functions called from Form_Current() event, otherwise docmd.gotorecord may fail.
if err.number=3059 then
- Edited by Eperbab Thursday, June 14, 2012 3:18 PM additional info about Doevents vs. gotorecord
dbFailOnError doesn't change the situation. Currentdb.openrecordset([datasource], [type]) + Escape generates error 3059. I made changes to my code according to Paul23's post (Saturday, June 25, 2011 10:59 PM):
Err_Handler: If Err.Number = 3059 Then Resume Next End If Resume fncImportRO_Exit
ForesterCA's post is a real help for Execute method. (Wednesday, May 16, 2012 2:06 AM)
In popup forms, I wanted the user to close the form by hitting the "ESC" key (or clicking a "close" button). But if the ESC key was pressed (to close form) and there was any function with an Execute or OpenRecordset in the closing procedure, the error 3059 occured.
Placing "DoEvents" at the beginning of the closing procedure or even only before Execute and OpenRecordset did work for me.
Before, I tried some workarounds like placing the "Sleep" command, changing the "KeyCode" to 0 or place "DoCmd.SetWarnings False", but all of them did not work...