VBA Access Function fncWriteError Code Only

Copy and paste this function (blue text) into a module from the Visual Basic Editor of your database.

Function fncWriteError(strForm As String, strModule As String, _
strProcedure As String, strErrNumber, strErrDescription, strErrLine, strMSG As String)
On Error GoTo fncWriteError_err:
10    Screen.MousePointer = 0
20    Dim s As String
30    s = Chr(10) & "Time: " & FormatDateTime(Now, vbLongTime) & Chr(10)
40    If strForm <> "" Then s = s & "Form: " & strForm & Chr(10)
50    If strModule <> "" Then s = s & "Module: " & strModule & Chr(10)
60    If strProcedure <> "" Then s = s & "Procedure: " & strProcedure & Chr(10)
70    s = s & "Error Number: " & strErrNumber & " " & strErrDescription & Chr(10)
80    s = s & "Line: " & strErrLine & Chr(10)
90    If strMSG <> "" Then s = s & strMSG & Chr(10) & Chr(10)
100   Debug.Print s
110   MsgBox s
Exit Function
fncWriteError_err:
MsgBox Chr(10) & "Error in fncWriteError" & Chr(10) & Err.Number & ": " & Err.Description & Chr(10)
Debug.Print Chr(10) & "Error in fncWriteError" & Chr(10) & Err.Number & ": " & Err.Description & Chr(10)
End Function

Comments

Popular Posts