Access™ 2007 VBA Programmer's Reference
by Teresa Hennig, Rob Cooper, Geoffrey Griffith, Armen Stein
7.1. Ambiguous References
In versions prior to Access 2000, the DAO object library reference was selected by default for new database solutions. This enabled you to write code using DAO without requiring you to realize that your code depended on this object model.
Starting in Access 2000, the ADO object library was referenced by default for new VBA projects (expecting you to use the ADO library for accessing data). Unfortunately, the change generated much confusion. It turned out that average Access developers didn't know the difference between the two object models. Many developers learned the hard way when their applications started generating errors in code that had previously worked.
By the time Microsoft realized the ramifications of adding ADO as the default reference, Access 2002 was already in beta, and the ADO reference remained. The issue was finally resolved in Access 2003 by referencing both object libraries by default. In Access 2007, there is another change to default references in databases:
ACCDB files have a reference to ACE DAO.
MDB files have a reference to DAO 3.6.
Of course, ADP files only have a reference to ADO 2.5 because DAO does not apply to SQL data sources.
Writing unambiguous VBA code has never been more important. There are likely thousands of Access applications that use code that does not reference a specific library when multiple references are present. If this code is run in a different version of Access than the version in which the database was ...
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