I have implemented an error handling routine in all of my form, and it seems to work, except that when I try to write to a table I get an error message that states------syntax error(missing operator) in query expression "(the error message)' , '(user)',
#(date/time)#, '(Form name)'-----the debugger stops on the cnn.execute line of code.---- Everything but the error message is able to write to a table--- it is funny because the other strings are fine. Is it something to do with my form_error event handler??
here is my routine Sub ErrorRoutine()
HELP PLEASE!!!!!!!
thanks,
Michael Oakes
#(date/time)#, '(Form name)'-----the debugger stops on the cnn.execute line of code.---- Everything but the error message is able to write to a table--- it is funny because the other strings are fine. Is it something to do with my form_error event handler??
here is my routine Sub ErrorRoutine()
Code:
'Declare my Variables
Dim Cuser As String
Dim strErrorDescription As String
Dim lngErrorNum As Long
Dim DateTime As Date
Dim FormName As Variant
'Set var's to current error
lngErrorNum = Err.Number
strErrorDescription = Err.Description
Cuser = CurrentUser()
DateTime = Now
FormName = Me.Form.Caption
'append the table tblErrorLog
Dim cnn As ADODB.Connection
Dim strSQL As String
Set cnn = CurrentProject.Connection
strSQL = "INSERT INTO tblErrorLog ( ErrorNum, ErrorString, CUser, CDateTime, FormName) "
strSQL = strSQL & "Select " & lngErrorNum & ", '" & strErrorDescription & "', '" & Cuser & "', #" & DateTime & "#, '" & FormName & "' "
MsgBox "Polaris Error Alert: Please document ! Your last action will be canceled---Error#: " & Err.Number & ": " & Err.Description, vbExclamation
cnn.Execute strSQL, , adExecuteNoRecords
DoCmd.CancelEvent
Exit Sub
End Sub
HELP PLEASE!!!!!!!
thanks,
Michael Oakes
Last edited by a moderator: