Sub ConnectionErrorHandler()
On Error GoTo Except
Dim Connection As ADODB.Connection
Set Connection = CurrentProject.Connection
Dim Recordset As New ADODB.Recordset
Recordset.Open "badTable", Connection
Exit Sub
Except:
Dim ADOError As ADODB.Error
For Each ADOError In Connection.Errors
MsgBox "ADO Error: " & ADOError.Description & " Native Error: " & _
ADOError.NativeError & " SQL State: " & _
ADOError.SQLState & "Source: " & _
ADOError.Source, vbCritical, "Error Number: " & ADOError.Number
Next ADOError
End Sub
|