Visual Basic Concepts

Handling Remote DAO Messages and Errors

See Also

Remote server systems generate their own litany of errors and messages. The database itself may contain procedures that generate user-defined messages or errors. Once DAO and the Jet database engine receive any error, regardless of the cause, the query that triggered the error is terminated. For those databases that use the SQL Server RaisError function to indicate warning-level messages, this may be problematic.

When using QueryDef objects to execute SQL pass-through queries, other messages received from ODBC and the remote server can be trapped. For example, SQL Server SQL PRINT statements generate a message that can be trapped by your code. To enable message trapping, your code must create a property named “LogMessages” for a specific QueryDef object, and set this property to True. Once set, messages generated by the selected QueryDef are recorded in a Jet table.

Each SQL query that Jet or the remote query processor executes can generate one or more ODBC or other remote-engine errors. All of these errors are stored in the Errors collection, which is accessible either during break mode or at run time. Documentation is available for some of these messages, especially those mapped by Jet to its own error numbers. Most ODBC operations will generate a generic ODBC trappable error that is explained more fully in messages found in other members of the Errors collection.

For More Information   See "Errors Collection" and "LogMessages Property" in the Language Reference.