Object Browser is a window that displays the classes, properties, methods, events, and constants in the available object libraries. A class is the basic pattern used when an object is created. Classes, such as App, Collection, or Control, define the methods, properties, and events for an object. An object is created at runtime from a class
contained in the object libraries. You can use the Object Browser window to examine all the objects that are available in VBA and in Access. You can also display help information on any object by using the Object Browser window.
To display the Object Browser, choose View, Object Browser in VBE, or click the Object Browser button on the Visual Basic toolbar. Pressing F2 in the VBE can also open Object Browser.
NOT FOR PRINTING OR INSTRUCTIONAL USE
Visual Basic Editor
1
–15
Project/Library list
Methods/Properties list Objects/Modules list
Details pane
Exhibit 1-3: The Object Browser window
The Object Browser window, as shown in Exhibit 1-3, uses various object libraries and displays the following information:
• Project/Library list. This displays the available object libraries, from which you can select one. A library is a file that contains all information about various classes, objects, procedures, and functions. By default, the Project/Library list contains <All libraries>.
• Classes list. This displays the various classes that are available in the object library selected in the Project/Library list. The properties, events and methods of an object are defined in class.
• Members Of <classname> list. This displays the methods and properties that belong to the object that is selected in the Classes list.
• Details pane. This displays some explanation about the selected project, library, class, methods, or properties. For example, if you select a method from the Objects/Modules list, the Details pane displays the method name, its syntax, arguments (if available), and the name of the library to which it belongs.
NOT FOR PRINTING OR INSTRUCTIONAL USE
1
–16
Access 2003: VBA ProgrammingDo it!
B-1: Examining the Object Browser window
Here’s how Here’s why
1 SelectfrmProduct
Open the Code window Click the Code button on the Database toolbar.
Tell students that they can also press F2 to open the Object Browser window.
2 ChooseView, Object Browser
(To open the Object Browser window.
Maximize the window, if necessary.) You’ll view the various objects and classes of the Access library and their methods and events by using Object Browser.
3 Observe the Project/Library list By default, All Libraries appear.
4 From the Project/Library list, selectAccess
You’ll view the information about the Access library.
5 Observe the Objects/Modules list It shows all the objects and modules that are available in the Access library.
6 From the Objects/Modules list, selectForm
Scroll down the list.
7 Observe the Methods/Properties list
(Scroll through the list.) It shows all the methods and properties that are available for the Form object. A green brick indicates methods and a hand icon pointing to an index indicates properties.
8 From the Methods/Properties list, selectWindowHeight
(In the lower part of the list.) To view the details of this property.
9 Observe the Details pane It shows the details of the WindowHeight property.
NOT FOR PRINTING OR INSTRUCTIONAL USE
Visual Basic Editor
1
–17 Object Browser’s search feature
Explanation You use the search feature of the Object Browser to view the methods, properties, and events of an object. To do so, enter the name of the project, database, or object whose information you want to view, then click the Search button. The Object Browser searches for the text you entered and displays the results in the Search Results section, as shown in Exhibit 1-4.
Search Text box Search button
Search Results section
Exhibit 1-4: The Object Browser with the Search Results section
NOT FOR PRINTING OR INSTRUCTIONAL USE
1
–18
Access 2003: VBA ProgrammingDo it!
B-2: Searching in the Object Browser
Here’s how Here’s why
1 From the Project/Library list, selectAll Libraries
2 In the Search Text box, enter Form_frmRetailer
You’ll use the Object Browser to view the methods, properties, and events of all objects in Form_frmRetailer.
3 Click (The Search button is in the Object Browser
window.) To start search. After the search is complete, the Search Results section is added to the Object Browser window.
4 Observe the Search Results section
This displays the VBAWindow1 as library and Form_frmRetailer as class.
. 5 Observe the Classes list The classes in VBAWindow1 appear in bold.
Tell students that they
need to scroll down. 6 Observe the members of the
‘Form_frmRetailer’ list
The methods, properties, events, or constants that have code written for them appear bold.
7 Under Members of
‘Form_frmRetailer’, select Form_Activate
Observe the Details pane of the window
This section displays the method name, its syntax, and arguments, if available.
8 From the Project/Library list, selectVBA
You’ll search for a function called ‘cInt’
provided by the VBA library.
9 Edit the Search Text box to read cInt
To provide the name of the function.
10 Click To start the search.
11 Observe the Search Results section
This displays VBA as library, Conversion as class, and Clnt as member.
12 Observe the Classes list This displays the class Conversion in a dotted box.
13 Observe the Members of
‘Conversion’ list
This displays the function Clnt in a dotted box.
NOT FOR PRINTING OR INSTRUCTIONAL USE
Visual Basic Editor
1
–19
14 Close the Object Browser Click the Close Window button on the upper right corner of the Code window.
15 Switch to Access
Close the form To return to the Database window.