Connecting to a Database

Chapter 7, “VBA Essentials Reviewed,” mentioned that there are differences between Data Access Objects (DAO) and ActiveX Data Objects (ADO). In some areas, the two are identical—at least from the perspective of writing the code that uses the objects. For example, one way to move from one record to the next is

EmployeeRecords.MoveNext

You can use that command whether you've established your connection to the database with DAO or with ADO.

In other areas, the two object libraries couldn't be more different. The older DAO approach involves a strict hierarchy and your code has to observe it. A typical DAO sequence of events is as follows:

1.
Set an object variable, such as TheDB, that represents a database.
2.
Set another ...

Get Managing Data with Microsoft® Excel now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.