P
PJFry
I am developing a new database and I want to be able to capture errors in a
table so I can sort through them without having the users try and send me
screen shots and such. Below is the code that I have on my OnCurrent event.
This code did not produce an error. It does exactly what I want it to do as
long as there is a value in the combo box. If the value is missing I should
get a syntax error. What is puzzling me is that when there is *no* error,
the error handler passes an error with a null description to the Error Log.
When there is an actual error, the sub shows me the error and stops without
recording that error.
I am somewhat new to error handling. Thoughts?
Private Sub Form_Current()
On Error GoTo Err_Handler
Set rs = New ADODB.Recordset
Set cn = CurrentProject.Connection
strSQL = "SELECT * FROM tParish WHERE ID = " & Me.cboParish.Column(0)
rs.Open strSQL, cn
txtParishPhone = rs!txtPhone
rs.Close
Set rs = Nothing
Err_Handler:
'MsgBox Err.Description
strErr = "INSERT INTO tErrorLog(txtErrDesc,txtUserID,dtmErr,txtForm) " & _
"VALUES ('" & Err.Description & "','" & fOSUserName() & "','" & Now() &
"','" & Me.Name & "')"
DoCmd.RunSQL strErr
Exit Sub
End Sub
Or can someone suggest a simplier way to do this?
Thanks!
PJ
table so I can sort through them without having the users try and send me
screen shots and such. Below is the code that I have on my OnCurrent event.
This code did not produce an error. It does exactly what I want it to do as
long as there is a value in the combo box. If the value is missing I should
get a syntax error. What is puzzling me is that when there is *no* error,
the error handler passes an error with a null description to the Error Log.
When there is an actual error, the sub shows me the error and stops without
recording that error.
I am somewhat new to error handling. Thoughts?
Private Sub Form_Current()
On Error GoTo Err_Handler
Set rs = New ADODB.Recordset
Set cn = CurrentProject.Connection
strSQL = "SELECT * FROM tParish WHERE ID = " & Me.cboParish.Column(0)
rs.Open strSQL, cn
txtParishPhone = rs!txtPhone
rs.Close
Set rs = Nothing
Err_Handler:
'MsgBox Err.Description
strErr = "INSERT INTO tErrorLog(txtErrDesc,txtUserID,dtmErr,txtForm) " & _
"VALUES ('" & Err.Description & "','" & fOSUserName() & "','" & Now() &
"','" & Me.Name & "')"
DoCmd.RunSQL strErr
Exit Sub
End Sub
Or can someone suggest a simplier way to do this?
Thanks!
PJ