Share this Page URL
Help

Chapter 17. From DAO to ADO > Accessing the Data by Recordset - Pg. 275

From DAO to ADO DAO Object -- ADO Object Stream 275 Opening a Database In DAO, you must use a Database object to access a database. ADO uses a Connection object to access a database. In DAO, you can use the CurrentDB function to determine the currently loaded database. ADO, on the other hand, provides you with the Access project's current connection to the SQL Server/MSDE database with CurrentProject.Connection. In DAO, write the following commands: Dim db As DAO.Database Set db = CurrentDB In ADO, use the following format: Dim cnn As ADODB.Connection Set cnn = CurrentProject.Connection Note that in ADO, you must generally use New to create a new Connection object, for example: Set cnn = New ADODB.Connection The only exception is the assignment, by reference, of CurrentProject.Connection , as this means that the CurrentProject object's Connection object already exists. In other cases, you may not use New keyword when an object is automatically created by calling a method of another object.