Error handling problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rghertner
    New Member
    • Jan 2008
    • 4

    #1

    Error handling problem

    Hi all,

    I've been away from Access error handling for a while, and now that I've returned I can't figure out what I'm doing wrong here.

    The following code doesn't pick up the error when there is one.
    Code:
    On Error GoTo error_handler:
    
    'Code here
    
    Exit Sub
    
    error_handler:
        Call errorhandler(Err.Number, Err.Description, Me.Name, "Search_Click")
    End Sub
    But if I move the goto to the following line after a resume next, it works fine.

    Code:
    On Error Resume Next
    GoTo error_handler:
    
    'Code here
    
    Exit Sub
    
    error_handler:
        Call errorhandler(Err.Number, Err.Description, Me.Name, "Search_Click")
    End Sub
    What am I missing here?

    Thanks
    Robin
  • emsik1001
    New Member
    • Dec 2007
    • 93

    #2
    Hi

    Try removing :

    so instead
    On Error GoTo error_handler:

    Try
    On Error GoTo error_handler

    I hope it helps
    Emil

    Comment

    • Rghertner
      New Member
      • Jan 2008
      • 4

      #3
      Thanks for the response, and sorry for the delay. I tried removing the colon, but no luck. Still doesn't catch the error.

      Comment

      • PianoMan64
        Recognized Expert Contributor
        • Jan 2008
        • 374

        #4
        Originally posted by Rghertner
        Thanks for the response, and sorry for the delay. I tried removing the colon, but no luck. Still doesn't catch the error.
        Do you have a subroutine that isn't part of the current module that is not valid, that it is stuck in a loop?

        Not sure, but just guessing since there isn't anything showing the sub call that you do inside the error message?

        Just a thought,

        Joe P.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          In your second version going to the error handler works, but it doesn't appear to be dependent on hitting any error. It will go there in ALL circumstances.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32669

            #6
            Robin,

            Have you actually compiled this code at all? It seems to have some basic errors in it (I'm referring to the obvious one of having a ":" in a GoTo statement.

            It may fail to catch this as it's also used as a command separator within a single line, but it's wrong nevertheless and compiling code before posting is ALWAYS a good idea.

            Comment

            Working...