-
Retrieving the form name as "me.name" is similiar to what I wish to do with a Sub or Function's name.
If I have "Private Function PTSBuildReport(rsReport As Recordset)" and an error occurs, how might I retrieve:
Err.Number & Me.Name & "Sub/Function Name"?
Thanks!
Nick
-
I don't think there is a way to retrieve the name via code. But if you handle the errors within your subs/functions, then you copuld do this:
Code:
Private Sub MyFirstSub1()
On Error Goto ErrHandler
'...Regular sub code comes here...
Exit Sub
ErrHandler:
MsgBox Err.Number & ": " & Err.Description & vbCrLf & "MyFirstSub1" & ", " & Me.Name
End Sub
Private Function AnotherFunction34() As String
On Error Goto ErrHandler
'...Regular function code comes here...
Exit Function
ErrHandler:
MsgBox Err.Number & ": " & Err.Description & vbCrLf & "AnotherFunction34" & ", " & Me.Name
End Function
Private Sub MyOtherCoolSub()
On Error Goto ErrHandler
'...Regular sub code comes here...
Exit Sub
ErrHandler:
MsgBox Err.Number & ": " & Err.Description & vbCrLf & "MyOtherCoolSub" & ", " & Me.Name
End Sub
Since you know the names of your subs/functions you can just store them at design-time.