Well,
I use an error trap that keeps track of them in a table. This isn't always the "best" situation, but for me it works. I used to keep them in a text file, but it really seems easier to write them to a table and then view them later.
Public Function MyErrorHandler(Optional location As String)
'Exit Function 'breaks function so that Sites don't errors log anymore.
Dim db As Database
Dim myrecord As Recordset
Set db = CurrentDb()
Set myrecord = db.OpenRecordset("ErrorsInSystem"
'From the form object, you can get the name from the .Name property:
Dim Frm As Form
Dim strFormName As String
Set Frm = Screen.ActiveForm 'error may occur here 2475 if no active window
strFormName = Frm.Name 'form name
'makes sure location is set.
If Len(location) < 3 Then
location = "Unknown"
End If
'updates ErrorsInSystem table
With myrecord
.AddNew
![When] = Now()
![Who] = [Forms]![Operator]![OperatorID]
If Err.Number > 0 Then
![ErrorNumber] = Err.Number
End If
If Len(Err.DESCRIPTION) > 0 Then
![ErrorMessage] = Err.DESCRIPTION
End If
If Len(strFormName) > 0 Then
![Form] = strFormName
End If
![ErrorLocation] = location
.Update
End With
'MsgBox ("There was an Error. Error has been logged, Error Number: " & Err.Number & ": " & Err.DESCRIPTION)
End Function
Randall Vollen
National City Bank Corp.