Microsoft Access 2010 Bible

(Rick Simeone) #1

Chapter 13: Accessing Data with VBA Code


501


Note
Microsoft Access 2007 introduced ACE (Microsoft Access Engine), a new database engine for the Microsoft
Office products. ACE is the reason why Access 2007 and 2010 support advanced features such as attachment
and multi-value fields. Because of the new data types, ACE required an updated version of DAO (called
ACEDAO) to support the new capabilities. The biggest differences between DAO and ACEDAO is the introduc-
tion of the Recordset2 and Field2 objects, plus new properties and methods required to support the fea-
tures introduced with Access 2007. Access 2010 continues to support DAO 3.6, the most recent version of
“traditional” DAO. Although this section describes traditional DAO, all the explanations and examples in this
section apply equally to ACEDAO as well. The Access 2010 .mdb format only supports DAO 3.6, and not
ACEDAO.


The DAO DBEngine object
The DBEngine object, which is the object representing the Jet engine, is at the very top of the
DAO hierarchy. It isn’t a member of any collection, and all collections are children of DBEngine.
There is only one instance of this object, and it’s one of the few data access objects that you can’t
create yourself. You open the DBEngine object when you start Access and issue a DAO operation.
It has very few properties and methods. For property changes to take effect, they must be issued
before a data access object operation has been performed; otherwise, you’ll receive an error.
Because DBEngine is at the top of the hierarchy, you almost always begin a DAO code sequence
with DBEngine.

The DAO Workspace object
A Workspace object represents an open, active session for each user working with Access. All
databases are opened within a workspace, either as a default database session or one that has been
created using the CreateWorkspace method of the DBEngine object.

Tip
If you choose to use transaction tracking (BeginTrans...EndTrans) within your application, these state-
ments include all recordsets opened within the current workspace. If you don’t want to use transactions with a
particular recordset, create a new workspace and open the recordset within the new Workspace object.


Security is also implemented from Workspace objects (but, only for the .mdb file format). The
security methods available to Workspace objects allow you to create your own security interfaces
and routines. If necessary, you can create users or groups using the CreateUser or
CreateGroup methods of the Workspace object.

Note
User-level security is not discussed in this book. Refer to the Access 2007 Bible for a discussion of user-level
security as applied to Access 2007 and 2010.

Free download pdf