Access™ 2007 VBA Programmer's Reference
by Teresa Hennig, Rob Cooper, Geoffrey Griffith, Armen Stein
E.2. Errors Collection and Error Object
The Errors collection contains all Error objects created by a response to a provider-related failure. The Error object contains the details about the error; it also has properties and methods you can use within your code. Any operation that involves an ADO object can generate errors. Every time another error occurs for the same object, an additional Error object is added to the Errors collection.
One caveat of error processing is that when a new ADO operation generates an error, the Errors collection is cleared and a new set of Error objects can be added to the Errors collection. It is common to use error-handling routines to examine the Error objects in the Errors collection to react to possible errors. This allows you to display helpful error messages in plain language rather than relying on the system to generate errors that are incomprehensible to inexperienced users.
E.2.1. Properties of the Errors Collection
The various properties of the Errors collection are summarized in the following table.
| Property | Data Type | Description |
|---|---|---|
| Count | Long | Returns the number of error objects stored in the Errors collection. |
| Item | String or Long | References a specific member of the Errors collection by name or ordinal number. |
E.2.2. Methods for the Errors Collection
The following table describes the methods available for the Errors collection.
| Method | Description |
|---|---|
| Clear | Removes all Error objects from the Errors collection. |
| Refresh | Updates the Errors collection to encompass ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access