Ing with Access

In older versions of Microsoft Office, there were two choices for working with data stored in Access tables. One was the Data Access Objects (DAO) object model, which was developed specifically to work with Access data in recordsets (including form recordsets) and to work with table structure using the Tables (and subsidiary Fields) collections. Because of these customized features, DAO was the best object model for working with Access data.

The other choice for working with Access data was (and is) the ADO object model, introduced with Visual Studio 97, and available for use in Office 2000 and up. This object model is intended for working with data in a wide variety of sources, including Access databases. Although it lacks some of the customized features that make DAO so well suited to Access data, ADO code works fine for basic data manipulation, where you don't need to work with Access form recordsets or create tables and fields (in other words, you are just working with data in Access tables, not with their structure).

Before the release of Office 2007, word was out that Microsoft was dropping support for the DAO object model (and indeed you can see statements to this effect in various online Microsoft documents). I wondered whether ADO would be updated to work with form recordsets, and the Tables (and subsidiary Fields) collection (or some alternate method for creating tables and their fields programmatically), because there are situations when you need these features of DAO, while working in an Access database, or creating an Access add-in.


Using the old and new DAO object models to work with Access data

Working with Access databases in formats from 2000 to 2007

Using the ADO object model to work with Access data

Converting DAO code to ADO code

F DAO library references older than 3.6 are not supported in Access 2007. This means that if you have references to older DAO versions in any older format databases you want to work with in Access 2007, you will need to reset these references to DAO 3.6. Databases that were created in Access 2000 format with a DAO 3.6 reference, when opened in Access 2007, still have a reference set to the DAO 3.6 object model (as shown in Figure 5.1), and their DAO code compiles and runs. The same is true of Access 2002/2003 format databases opened in Access 2007.


A reference to the DAO 3.6 object model in an Access 2000 database opened in Access 2007.

References - Northwind

Available References:

0 Visual Basic For Applications 0 Microsoft Access 2007 (Beta) Object Library 0 OLE Automation

0 Microsoft Office 12,0 Obiect Librarv

Microsoft DAO 3.6 Object Library

[j AccessibilityCplAdmin 1.0 Type Library

□ Active DS Type Library

□ ActiveMovie control type library

□ AP Client 1.0 HelpPane Type Library

□ AP Client 1.0 Type Library

□ Assistance Platform Client 1.0 Data Services Type Lit

□ ATLContactPicker 1.0 Type Library i 1 a7rnlps 1. H Tvnp I ihrarv



Mtrosoft DAG 3.E Object Library

Location: J:^rogram Files^ommon FilesY1icio5oft5haredV3AO\dao360 Language: Standard

As it turned out, the DAO object model is still supported, though with some changes. If you convert an earlier format database to Access 2007 format, or create a new Access 2007 database, by default it has a reference to the Microsoft Office 2007 Access database engine object model (file name: ACCESS 2007 DAO.DLL). This new object model (which I will hereafter reference as Access 2007 DAO) has the same core functionality as DAO 3.6 (with a few differences, which are discussed in the "New Objects in the Access 2007 DAO Object Model" section), and the same object model abbreviation (DAO) for use in declarations, so Microsoft hasn't really pulled DAO after all — instead, they renamed it, added a new object and a few new attributes, and hid some of the components that are not directly related to working with Access data.

This means that all your old DAO code will run the same as before, so you don't need to convert it to ADO (though of course you can, if you want to use the more modern ADO object model), and if you are working with an Access 2007 database, you will have a few new object model components that represent the new features in Access 2007.

The sample database for this chapter is DAO and ADO Sample Code.accdb. In addition, - SSssk gome of the code references the sample database Northwind 2007.accdb, which you can create by double-clicking the Northwind.accdt template in the C:\Program Files\ Microsoft Office\Templates\1033\Access folder.

The default Access 2007 DAO reference in a new Access 2007 database.

References - Databasel


Available References:

OK 1

S! Microsoft Access 2007 (Beta) Object Library

0 OLE Automation


Cancel |

MISH!WliI.i: -fBB.tMJ-JJ.IJJ.ira

Browse.,, |

!_! AccessibilityCplAdmin 1,0 Type Library Q Active DS Type Library 1 ] ActiveMovie control type library

□ AP Client 1.0 HelpPane Type Library

□ AP Client 1.0 Type Library

D Assistance Platform Client 1.0 Data Services Type Lit

1 1 ATLContactPicker 1,0 Type Library

□ azroles 1.0 Type Library

Rarfci in anrl Reslnr? fnntrnl Panpl Tvn^ 1 ihrarv

■ i in >


Hdp 1

Microsoft Office 2007 Access database engine Object Library

Location: JiVrogram Files Microsoft Office\Officel2\ACEDAO.DLL

Language: Standard

0 0

Post a comment