O'Reilly logo

Access™ 2007 VBA Programmer's Reference by Armen Stein, Geoffrey Griffith, Rob Cooper, Teresa Hennig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required