Currently I use a Error module to trap errors in access but I have trouble with trapping ODBC errors. I found this code but Where would I put this function so I can trap ODBC errors?
http://support.microsoft.com/kb/209855
Here is my error trapping code:
Plus, if anyone can see any suggestions on how to log the errors better or other information I should be logging please do not hesitate.
http://support.microsoft.com/kb/209855
Here is my error trapping code:
Code:
Sub UnknownError(strSub As String, lngErrCode As Integer, strErrDesc As String, Optional strControl As String)
LogError strSub, lngErrCode, strErrDesc, strControl
DoCmd.OpenForm "frmGeneralError"
Forms!frmGeneralError.lblError.Caption = strSub & " - " & "Error#" & lngErrCode & ": " & strErrDesc
End
End Sub
Code:
Sub LogError(strSub As String, lngErrCode As Integer, strErrDesc As String, Optional strControl As String)
Dim cnn As ADODB.Connection
Dim strSQL As String
Set cnn = CurrentProject.Connection
strSQL = "INSERT INTO tblLog (ErrorNum, ErrMessage, UserName, ErrTime, BuildNum, CurrentSub, CurrentControl) "
strSQL = strSQL & "VALUES ( " & lngErrCode & ", '" & strErrDesc & "', '" & strUserLogin _
& "', #" & Date & "#, '" & DLookup("[VersionNum]", "tblVersion", "[VersionID] = 1") & _
Format(DLookup("[VersionMinNum]", "tblVersion", "[VersionID] = 1"), ".00") & _
Format(DLookup("[BuildNo]", "tblVersion", "[VersionID] = 1"), ".00") & "', '" & strSub & "', '" & _
strControl & "' ) "
cnn.Execute strSQL, , adExecuteNoRecords
End Sub
Plus, if anyone can see any suggestions on how to log the errors better or other information I should be logging please do not hesitate.