Databases Reference
In-Depth Information
Here are some caveats to keep in mind with respect to closing objects:
As we will see in Chapter 16, you should update (i.e., complete) all pending edits
before closing an open
Recordset
object.
•
When a procedure that declares a
Recordset
or
Database
object is exited, the
recordset or database is closed, and any unsaved changes or pending edits are lost.
•
If you close a
Database
object while any
Recordset
objects are still open, or if
you close a
Workspace
object while any of its
Database
objects are open, those
Recordset
objects will be automatically closed, and any pending updates or edits
will be lost.
•
14.8 A Look at the DAO Objects
Now we can look briefly at each of the collections (and their objects) in the DAO Object
Model. I 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.
14.8.1 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.
14.8.2 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