O'Reilly logo

F. Scott Barker's Microsoft® Access 2000 Power Programming by F. Scott Barker

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

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

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