Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Location
    OHIO
    Posts
    75

    Unanswered: trapping multiple error messages

    Just looking for a snip of code that traps multiple error messages...

    Also, in one of my reports, if there is no information to be displayed...(the report comes up empty) I need something that just pops-up and says "no data to display"....

    TIA

    BAF

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: trapping multiple error messages

    Originally posted by ironchef
    Just looking for a snip of code that traps multiple error messages...

    Also, in one of my reports, if there is no information to be displayed...(the report comes up empty) I need something that just pops-up and says "no data to display"....

    TIA

    BAF
    Try looking at the Errors collection. Your 2nd issue:

    Private Sub Report_NoData(Cancel As Integer)

    End Sub

    Do your message box in the NoData event of the report ...

  3. #3
    Join Date
    Feb 2004
    Location
    Houston, Texas
    Posts
    45
    Here's some code I 'borrowed' from some journal years ago that has been working for me:

    where:
    Const cstrProc As String = "Name of Sub or Function"

    ...this get's added to your sub or function
    XXX_Exit:

    XXX_Err:
    Select Case c_ErrorHandler(cstrProc, Err.Number, Err.DESCRIPTION)
    Case 1
    Resume
    Case 2
    Resume Next
    Case 3
    "Some message"
    Resume XXX_Exit
    Case 4
    Stop
    Resume
    Case Else
    End Select
    -------------------
    this is the error handler:

    Function c_ErrorHandler(ByRef strProgName As String, _
    ByRef lngErrNumber As Long, _
    ByRef strErrDescription As String, _
    Optional ByVal str1 As String, _
    Optional ByVal str2 As String) As Long


    Select Case lngErrNumber
    Case 0 'No Error
    c_ErrorHandler = 3 'Exit Procedure or Function
    Case 13 'Type mismatch
    c_ErrorHandler = 3 'Exit Procedure or Function
    Case 52
    c_ErrorHandler = 3 'resume next DOS Error
    Case 53
    c_ErrorHandler = 2 'resume next DOS Error
    Case 76
    c_ErrorHandler = 2 'path not found...
    Case 2424 'couldn't find control or table... usually because the external DB not connected yet...
    c_ErrorHandler = 3 'resume next
    Case 3034 'Rollback error
    c_ErrorHandler = 2 'resume next
    Case 3265 'table name not in collection
    c_ErrorHandler = 3 'exit sub with no message
    'Case -2147220592
    ' c_ErrorHandler = 3 'Exit Procedure or Function
    Case Else
    c_WriteToLog strProgName, lngErrNumber, strErrDescription, str1, str2
    MsgBox strProgName & vbCrLf & vbCrLf & strErrDescription, , "Error Log"
    c_ErrorHandler = 3 'Exit Procedure or Function
    End Select
    DoEvents

    '------

    End Function

    Hope this is clear enough, customize at will...
    rtk

  4. #4
    Join Date
    Jan 2004
    Location
    OHIO
    Posts
    75

    Cool

    thanks for the help!!

Posting Permissions

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