Results 1 to 12 of 12
  1. #1
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Runtime error not functioning A2007

    My runtime error code doesn't "run" in A2007. The program acts as if there were no OnError goto etc. Here is an example. When I run this, I get the pop up announcing run-time error 2002 . I was told that removing Option Explicit from the declarations section would fix this, but not so. Using W7 on 64 bit computer.



    Private Sub import_Click()
    On Error GoTo Errx
    DoCmd.RunCommand acCmdImport 'In A2007 , will generate err 2002

    call GoImport
    Exit Sub


    Errx:
    If err.Number = 2002 Then 'means using Acess 2007, need different command
    DoCmd.RunCommand acCmdImportAttachAccess
    call GoImport
    End If


    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You have no action if it is an error other than 2002. It just exits the sub. At least show a MsgBox with the error. Have you single stepped to see if it is throwing an error?

  3. #3
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Quote Originally Posted by RuralGuy View Post
    You have no action if it is an error other than 2002. It just exits the sub. At least show a MsgBox with the error. Have you single stepped to see if it is throwing an error?
    Hi and Thanks for quick reply. I did single step and only gets to the first import expression, then pops up with the very run-time error message that (2002) that I am trying to trap. I have tried the repair utility to no avail. any ideas?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I just tried your code in a 2007 accdb and it worked just fine. Single stepping, it took the OnErr trap. Is your system fully patched? Both ac2007 and the OS!

  5. #5
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    I get all the updates regularly, but did it again to make sure, both for Office and W7. I also ran the repair utility, then uninstalled and reinstalled Office 2007 and downloaded service pak 2. Still no good. It isn't just for this code, but for all my code. It just won't recognize onError. Ever hear of it before or know where I might go to find something out? Runs ok on my wife's machine with w7 and A2003

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    When you open a module with code and go to Tools>Options>General tab - how to you have error trapping set?

  7. #7
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Hi-and thanks again. It is set for "break on all errors" I tested it on a simple form with one button coded to open a non-existent form. When I changed it to "break in class module", it trapped the error. When I leave it on "break all errors", it doesn't trap. I must not know what "break" means. Intuitively, it would seem that Break on All is what I would want. Do I change it to the class option and how would I make it the default mode if so.?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I leave mine at "Break on Unhandled Errors".

  9. #9
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Thanks so much. If you are ever in the SF Bay Area, I owe you at least the first 3 rounds. This was driving me crazy. Your willingness to stay with it to the end is much appreciated.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I used to live in Hayward, Belmond and Redwood City. Have fun.

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    BTW, are you ready to follow the link in my sig and mark this thread as Solved?

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by RuralGuy View Post
    BTW, are you ready to follow the link in my sig and mark this thread as Solved?
    Nevermind. I see you got it. Thanks.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. runtime error 3219
    By Rider570 in forum Programming
    Replies: 3
    Last Post: 07-07-2010, 09:12 PM
  2. Replies: 3
    Last Post: 04-15-2010, 09:43 AM
  3. runtime error 2448
    By ds_8805 in forum Forms
    Replies: 3
    Last Post: 04-14-2010, 07:32 PM
  4. Help With Runtime Error 4248
    By KLahvic in forum Programming
    Replies: 1
    Last Post: 04-09-2010, 07:47 AM
  5. Runtime 3075 error
    By whm1 in forum Programming
    Replies: 4
    Last Post: 03-24-2010, 02:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums