Results 1 to 3 of 3

Thread: error handler

  1. #1
    Join Date
    Apr 2004
    Posts
    100

    Unanswered: error handler

    hi,

    quick question:
    is it possible to have more than one error handler in one single event?
    I have ON ERROR GOTO ERR_MYERR and one ON ERROR RESUME NEXT in the same event.
    anyone have experience with that?

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Sure. The following On Error cancels out the previous On Error. The last On Error statement sequentialy encountered through code operation is the one that has final effect. For Example:

    Code:
    Private mySubRoutine()
    On Error Resume Next
    'Form Doesn't exist...so, skip past it...
    DoCmd.OpenForm "DummyForm"
     
    On Error GoTo myFirstGoto
    '.............................
    ' whatever code here
    '...........................
     
    On Error GoTo mySecondGoto
    '.............................
    ' whatever code here
    '...........................
     
    FinishUpHere:
    Exit Sub
     
    myFistGoto:
    Err=0: Resume FinishUpHere
     
    mySecondGoto:
    If Err = WhateverErrorNumber Then
    	 '.............................
    	 ' whatever code here
    	 '...........................
    End If
    Resume FinishUpHere
    End Sub
    For a larger application, it's sometimes best to have a global Error Handling Routine which will pull the specific error out of a table and display the specifics to the user.


  3. #3
    Join Date
    Apr 2004
    Posts
    100
    Many Thanks for the code !!!!! Thank you very much!

Posting Permissions

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