OPENING A CONNECTION TO A DATABASE

You first need to open a connection to a database. As in DAO, creating a reference to a database is pretty straightforward in ADO.

Connecting to the Current Database

Connecting to the current database (or project, as is popular in Access 2000) is the easiest of all. To perform this task, you use the CurrentProject object, which is a property of the Application object. The CurrentProject object has a Connection property, which you assign to a Connection object. You can see this in the following code, which prints the ConnectionString property to the Immediate window:

 Sub DisplayLocalConnection() Dim cnnLocal As ADODB.Connection Set cnnLocal = CurrentProject.Connection Debug.Print cnnLocal.ConnectionString End ...

Get F. Scott Barker's Microsoft® Access 2000 Power Programming 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.