Results 1 to 5 of 5
  1. #1
    Join Date
    May 2004
    Posts
    65

    Unanswered: On Error Not working

    I have a working database that has suddenly stopped handling errors:

    2003 (previously converted from 2000)

    Code:

    On Error Resume Next
    DoCmd.DeleteObject acTable, "trrep"
    DoCmd.DeleteObject acTable, "trrepc"
    On Error GoTo 0

    I have tried changing the code to

    On error goto errorhandlingcode

    and then

    If err.number = 7874 then ...

    but that doesn't do anything.

    Appreciate your help

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Is your if statement under a heading of errorhandlingcode: ? If not, how is access supposed to know where it goes on error?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    May 2004
    Posts
    65

    Resolved

    It was operating successfully with the
    On error resume next

    and later

    On error goto 0

    Which allows me to ignore the error.

    The actual problem related to the external database I was accessing the table I was trying to delete and for some reason was not being captured or ignored.

    Thanks anyway

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Woah... you might want to brush up on error handling... If you're telling it to goto 0 on error, you're initiating an infinant loop. On Error Resume Next will always ignore every error in the sub, you don't need to do anything else after that line.

    goto statements are usually reserved for executing a block of code ie:

    On Error Goto MyHandler

    'some code that might error

    Exit Sub/Function here so you don't always execute the handler

    MyHandler:
    If err.Number = whatever Then
    do stuff
    End If
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    go in the code editor, select tools in the menu, then options and have a look at the screenshot setting
    Attached Thumbnails Attached Thumbnails onerror.jpg  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •