Trapping Errors

One of the most powerful features of Visual Basic is its ability to trap all errors, analyze them, and take corrective action. In a well-designed production application, the user should never see any of the default error messages or encounter a code halt when an error occurs. Also, setting an error trap is often the best way to test certain conditions. For example, to find out if a query exists, your code can set an error trap and then attempt to reference the query object. In an application with hundreds of queries, using an error trap can also be faster than looping through all QueryDef objects. To enable error trapping, you use an On Error statement.

On Error Statement

Use an On Error statement to enable error trapping, establish ...

Get Microsoft Office® Access 2007 Inside Out now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.