Access.2007.VBA.Bibl..

(John Hannent) #1
new Access 2007 DAO object model as well as the old DAO object model. If you compare the
DAO (or Access 2007 DAO) and ADO object models, you will see Recordset, Parameter, and Field
objects in both.

When your code is compiled, if the declarations don’t include the object model, the first reference
in the list of references that contains that object name is used, and it may not be the right one. In
Access 2000 and XP (perhaps prematurely), new databases had a default reference only to the ADO
object model, which led to many problems for users and developers who were working primarily
or exclusively with DAO (see Figure 5.3). However, if you create a new database in Access 2003, in
the Access 2002/2003 database format, by default it will have references set to both the DAO and
ADO object models, in that order, as shown in Figure 5.4.

FIGURE 5.3
The default references for a new Access 2002 (XP) database.

This means that all Recordset, Field, and Parameter variables declared without an object model ref-
erence will be interpreted as belonging to the DAO object model, which may not be correct.

If your database was first created in Access 2000 or XP, and you didn’t set a reference to the DAO
object model, you will have the opposite problem — Recordset, Field, and Parameter variables will
be interpreted as belonging to the ADO object model, which could cause problems when working
with DAO object properties and methods.

Part II Writing VBA Code to Exchange Data between Office Components

Free download pdf