BUG in Access 2007: <Esc> raises run-time error 3059 RRS feed

All replies

  • 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
    Case 3059
       GoTo ExitHandler
       'Display error message, log the error, etc.

    End Sub


    Saturday, June 25, 2011 10:59 PM
  • Paul23

    Thank you for your quick response. Unfortunatelly, it is not a solution since OpenRecordset and Execute methods fail.

    Saturday, June 25, 2011 11:17 PM
  • Hello Vladimir,


    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.


    Best Regards,










    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.

    Wednesday, June 29, 2011 3:56 AM
  • Hello, Macy,
    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.

    "Re-register DLLs"
    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.

    "Clean registry"
    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.

    Wednesday, June 29, 2011 6:35 AM
  • Any solution, please?
    Friday, July 15, 2011 8:17 AM
  • Wednesday, May 2, 2012 9:54 AM
  • Place DoEvents before Execute

    In your example:

       CurrentDb.Execute sq, dbFailOnError

    Wednesday, May 16, 2012 2:06 AM
  • Hi, Forester,

    thank you very much! DoEvents is a great help. I will test it in various situations.

    Vladimir Cvajniga

    Wednesday, May 16, 2012 9:35 AM
  • 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:
    Currentdb.openrecordset(..,.., dbFailOnError)
    exit sub
    if err.number=3059 then
    end if
    'other errors
    end sub

    ** Edit: Do not place Doevents in functions called from Form_Current() event, otherwise docmd.gotorecord may fail.
    • Edited by Eperbab Thursday, June 14, 2012 3:18 PM additional info about Doevents vs. gotorecord
    Thursday, June 14, 2012 5:46 AM
  • Eperbab:

    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):

       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)

    Vladimir Cvajniga

    Thursday, June 14, 2012 8:12 PM
  • 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...

    Wednesday, June 19, 2013 7:21 AM