Getting Started

To run the code examples in this article, you need references to the ADO, ADOX, and JRO type libraries in your database or project. By default, new Microsoft Access 2000 databases have a reference to ADO. However, to run these samples you'll need to add references to ADOX and JRO. If you converted an existing database to Access 2000 or are programming in Microsoft Visual Basic® or some other application, you will need to include all of the references yourself.

To add these references in Access 2000

  1. Open a module.

  2. From the Tools menu, select References…

  3. From the list, select Microsoft ActiveX Data Objects 2.1 Library.

  4. From the list, select Microsoft ADO Ext. 2.1 for DDL and Security.

  5. From the list, select Microsoft Jet and Replication Objects 2.1 Library.

  6. Click OK.

To add these references in Visual Basic

  1. Open a project.

  2. From the Project menu, select References…

  3. From the list, select Microsoft ActiveX Data Objects 2.1 Library.

  4. From the list, select Microsoft ADO Ext. 2.1 for DDL and Security.

  5. From the list, select Microsoft Jet and Replication Objects 2.1 Library.

  6. Click OK.

If you include references to both ADO and DAO in the same project, you need to explicitly specify which library to use when declaring objects because DAO and ADO include several objects with the same names. For example, both models include a Recordset object, so the following code is ambiguous:

Dim rst as Recordset

To specify which object model you want to use, include a qualifier as shown:

Dim rstADO As ADODB.Recordset
Dim rstDAO As DAO.Recordset

If the qualifier is omitted, Visual Basic for Applications will choose the object from the model that is referenced first. So if your list of references is ordered as follows in the References dialog box, an object declared as Recordset with no qualifier would be a DAO Recordset.

Visual Basic for Applications
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.1 Library
Microsoft ADO Ext. 2.1 for DDL and Security
Microsoft Jet and Replication Objects 2.1 Library

Note   The code samples given in this article are intended for illustration only. They do represent the good techniques for sample code, but not necessarily for production code. Production-level code should account for error handling, object creation and reference counting, connection management, performance tuning, and so on. For example, the following technique for object creation is used in the samples:

Dim rst As New ADODB.Recordset

For better control over object creation and maximum performance, production code should use this technique instead:

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset