Remarks

The ODBCError object is a member of the collection. If the specified ODBC query runs without error, the ODBCErrors collection is empty. The errors in the collection are indexed in the order in which they're generated by the ODBC data source.

Example

Use (), where is the index number of the error, to return a single ODBCErrorobject. The following example refreshes query table one and displays the first ODBC error that occurs.

Visual Basic for Applications
With Worksheets(1).QueryTables(1) .Refresh If Application.ODBCErrors.Count > 0 Then Set er = Application.ODBCErrors(1) MsgBox "The following error occurred:" & er.ErrorString & " : " & er.SqlState Else MsgBox "Query complete: all records returned." End If End With
Describe ODBCError object? ODBC Error Object ODBCError ODBCError Object

See also:

index index