Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Reporting that includes function and module/form name

Status
Not open for further replies.

AlanJordan

Programmer
Sep 15, 2005
139
US
I call the sub ErrBox (see below) using code similar to this:

Code:
    ErrBox ("The problem originated in ResetAdjustButton in frmEditHoursWorked_AWP")
Can anyone suggest a way to automatically include the name of the sub and the name of the form? I have a feeling that I need to create an add-in, but I'm not sure of how to do this in Access. I do not have VB installed in this location.

Thanks,
Alan
Code:
Public Sub ErrBox(Optional varProblemType As Variant, Optional strUrgencyLevel As String, Optional dblNumRef1 As Double, Optional dblNumRef2 As Double)
'Note:  The case functionality has been anticipated, but no differentiation is made yet.

Dim strMsg As String

    If IsNull(varProblemType) Then 'there is a type of problem indicated
            strMsg = "There is a problem.  It is " & Err.Number & " - " & Err.Description & " -  Source: " & Err.Source & "."
            MsgBox strMsg
    Else
            Select Case varProblemType
            Case "FL"
               strMsg = "There is a problem.  It is " & Err.Number & " - " & Err.Description & " -  Source: " & Err.Source & "." _
               & vbCrLf & vbCrLf & "Note:  Tell a programmer that the problem originated while loading the form."
            Case 1
                strMsg = "There is a problem.  It is " & Err.Number & " - " & Err.Description & " -  Source: " & Err.Source & "."
            Case 2
                strMsg = "There is a problem.  It is " & Err.Number & " - " & Err.Description & "."
            Case Else
                strMsg = "There is a problem.  It is " & Err.Number & " - " & Err.Description & " -  Source: " & Err.Source & "."
            End Select
            MsgBox strMsg
            Call LogAMessage(strMsg, , CStr(varProblemType), "", dblNumRef1, dblNumRef2)
    End If
End Sub
 
How are ya AlanJordan . . .

Only way you can do this is to [blue]add additional arguements[/blue] in [purple]ErrBox[/purple] for those values and [blue]pass them accordingly from each calling sub/fuction.[/blue]

Thers's no function in VB/VBA to return or read the [blue]STACK[/blue] of sub/function calls. You'll have to do it manually this way!

Calvin.gif
See Ya! . . . . . .
 
If it's in a sub, you can return the name of the calling form using Me.Name Can't see one that returns the name of the sub/function though :( - Guess it doesn't exist!

Aubs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top