Setting Up References to Object Libraries

To work with Microsoft Access 2002 objects, begin by creating a reference to the Microsoft Access 10.0 Object Library. (Choose Microsoft Access 9.00 Object Library if you are working with Microsoft Office 2000.)

1. In the Visual Basic Editor window, choose Tools | References to open the References dialog box. This dialog displays a list of all the type libraries that are available on your computer.

2. Locate the Microsoft Access 10.0 Object Library in the list of entries and select its check box.

3. Close the References dialog box.

Once you've created a reference to the Microsoft Access type library, you can use the Object Browser to view a list of the application's objects, properties, and methods (see Figure 15-1 in the previous section).

Use the References dialog box to set up references to other object libraries that will be accessed in the exercises of this chapter. You will find the list of libraries in the previous section. You can skip the reference to the Microsoft Jet and Replication Objects 2.6 Library (JRO), as it will not be used here. If you are interested in database replication, there are many books on Microsoft Access programming that cover this subject, including my book Learn Microsoft Access 2000 Programming by Example from Wordware Publishing (ISBN 1-55622-770-1).

Tip 15-1: Advantages of Creating a Reference to Microsoft Access Object Library

When you set a reference to Microsoft Access Object Library, you gain the following:

■ You can look up Microsoft Access objects, properties, and methods in the Object Browser.

■ You can run Microsoft Access functions directly in your VBA procedures.

You can declare the object variable of the Application type instead of the generic Object type. Declaring the object variable as Dim objAccess As Access.Application (early binding) is faster than declaring it as Dim objAccess As Object (late binding). You can use Microsoft Access built-in constants in your VBA code. Your VBA procedure will run faster.

0 0

Post a comment