A Look at the DAO Objects

Now we can look briefly at each of the collections (and their objects) in the DAO Object Model. We will discuss each object and mention a few of the more commonly used properties and methods. A complete list of all collections, methods, and properties of each object is given in Appendix A.

DBEngine Object

The DBEngine object, of which there is only one, represents the Jet database engine. This is the only object in the DAO that is not contained in a collection. We have seen several examples of its use, along with the fact that the default collection for the DBEngine object is Workspaces, and so:

DBEngine.Workspaces(0)

is equivalent to:

DBEngine(0)

We have also seen that:

DBEngine(0)(0)

denotes the first database in the first (default) workspace.

The DBEngine object has methods to create a new workspace (CreateWorkspace), to compact a database (CompactDatabase), and to repair a database (RepairDatabase), among others.

Errors

From time to time, an operation may cause one or more errors to occur (or so I am told). When this happens, the Errors collection is first emptied and then filled with one Error object for each error that the operation caused. (Some operations may cause more than one error.) Note that if no errors occur, the Errors collection remains as it was before the operation.

Example 14.9, which deliberately produces an error, illustrates the use of the Errors collection. It also demonstrates the use of three Error object properties: Number (the VBA ...

Get Access Database Design and Programming, Second Edition 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.