HI,
I'm using Access 97 and I want to trap errors (any standard error message) and write those error messages to a file (.ext or notepad in a specific shared drive). This would help me track and record the number of errors that occur in our business enviornment. In addition, read errors that are ocurring from other users.
I have code that was given to me over a year ago, but I am struggling to understand how to decipher and use. I will paste it below. Feel free to provide original and more easier code to use!
Global Variable:
mNL$ = Chr$(13) & Chr$(10)
Sub mySub1()
On Error Goto err_mySub1
'Your Code for current sub or function
Exit Sub
err_mySub1:
Screen.MousePointer = DEFAULT
sLogError Error, Err
Select Case Err
Case 3021 'No Current Record
Resume Next
Case Else
mRetVal% = MsgBox("SubName999" & mNL & mNL & Error & mNL$ & mNL$ & "Error number: " & Str$(Err), MB_ICONINFORMATION, "Internal Error"
Resume Next
End Select
Return
Sub sLogError (pErrMsg As String, pErrNumber As Long)
On Error Resume Next
'Write Error To Error Log
Dim mLogFile As Integer
mLogFile% = FreeFile
Open app.Path & "\Error.log" For Append As #mLogFile%
Print #mLogFile%, "<<<<<<<<<< " & Date$ & " - " & Time$ & " >>>>>>>>>>" & mNL
Print #mLogFile%, pErrMsg$ & mNL$ & mNL$ & "Error number: " & Str$(pErrNumber)
Close #mLogFile%
End Sub
Thanks,
Clark
~Clark
I'm using Access 97 and I want to trap errors (any standard error message) and write those error messages to a file (.ext or notepad in a specific shared drive). This would help me track and record the number of errors that occur in our business enviornment. In addition, read errors that are ocurring from other users.
I have code that was given to me over a year ago, but I am struggling to understand how to decipher and use. I will paste it below. Feel free to provide original and more easier code to use!
Global Variable:
mNL$ = Chr$(13) & Chr$(10)
Sub mySub1()
On Error Goto err_mySub1
'Your Code for current sub or function
Exit Sub
err_mySub1:
Screen.MousePointer = DEFAULT
sLogError Error, Err
Select Case Err
Case 3021 'No Current Record
Resume Next
Case Else
mRetVal% = MsgBox("SubName999" & mNL & mNL & Error & mNL$ & mNL$ & "Error number: " & Str$(Err), MB_ICONINFORMATION, "Internal Error"
Resume Next
End Select
Return
Sub sLogError (pErrMsg As String, pErrNumber As Long)
On Error Resume Next
'Write Error To Error Log
Dim mLogFile As Integer
mLogFile% = FreeFile
Open app.Path & "\Error.log" For Append As #mLogFile%
Print #mLogFile%, "<<<<<<<<<< " & Date$ & " - " & Time$ & " >>>>>>>>>>" & mNL
Print #mLogFile%, pErrMsg$ & mNL$ & mNL$ & "Error number: " & Str$(pErrNumber)
Close #mLogFile%
End Sub
Thanks,
Clark
~Clark