Using the Object Browser to Display ADO Properties, Methods, and Events

At this point in your ADO learning curve, a detailed list of properties, enumerations of constant values, methods, and events of ADO components might appear premature. Understanding the capabilities and benefits of ADO, however, requires familiarity with ADO's repertoire of properties, methods, and events. To get the most out of ADP and to program DAP you must have a working knowledge of ADO programming techniques.

DAO objects don't fire events; ADO objects do. Access objects offer fine-grained events, but don't provide programmers with a lower-level event model for basic operations, such as connecting to a database and executing queries. Access 97's ODBCDirect offered an event model, but you couldn't bind ODBCDirect Recordsets to forms. ADO offers a complete and very fine-grained event model.

graphics/object_browser.gif Object Browser is the most useful tool for becoming acquainted with the properties, methods, and events of ADODB objects. Object Browser also is the most convenient method for obtaining help with the syntax and usage of ADO objects, methods, and events.

Note

graphics/access_2002_new_icon.gif

The examples and tabular list of properties, methods, and events of ADO objects in this and other related chapters are for ADO 2.6. Objects, methods, and events that are added by ADO 2.5+ are identified by the new in Access 2002 icon. (Access 2003's ADO 2.7 doesn't add any new elements.) If your .mdb or .adp file has a reference to ADO 2.1 or 2.5, your results for this chapter's examples might differ or fail to execute.


To use Object Browser with ADO objects, follow these steps:

  1. graphics/design_view.gif graphics/code.gif Open in design mode one of the forms of ADOTest.mdb that you created in the preceding sections, and then open the VBA Editor for its code. Alternatively, open the sample ADOTest.mdb or ADOTest.adp file.

  2. graphics/object_browser.gif Press F2 to open Object Browser.

  3. Select ADODB in the library (upper) list.

  4. Select one of the top-level components, such as Connection, in the Classes (left) pane.

  5. Select a property, event, or method, such as Open, in the Members of 'ObjectName' (right) pane. A short-form version of the syntax for the selected method or event appears in Object Browser's lower pane (see Figure 30.10).

    Figure 30.10. Object Browser displays in the status pane the syntax of the object class member you select in the Members of 'ObjectName' pane.

    graphics/30fig10.gif

  6. graphics/help.gif Click the Help button to open the help topic for the selected object, property, method, or event. Figure 30.11 shows the help topic for ADODB.Connection.Open.

    Figure 30.11. The Object Browser's help button opens the online VBA help topic for the selected ADODB object, method, property, or event. The See Also link leads to related help topics. If enabled, the Example link opens a sample VBA subprocedure. The Applies To link opens a list of objects that share the method, property, or event.

    graphics/30fig11.jpg

ADO type libraries also include enumerations (lists) of numeric (usually Long) constant values with an ad prefix. These constant enumerations are specific to one or more properties. Figure 30.12 shows Object Browser displaying the members of the ConnectModeEnum enumeration for the Mode property of an ADODB.Connection object. The lower pane displays the Long value of the constant.

Figure 30.12. Object Browser displays in the status pane the numeric value of members of ADO enumerations, which are a collection of related ADO constant values.

graphics/30fig12.gif

Tip

You can substitute the numeric value of enumerated constants for the constant name in VBA, but doing so isn't considered a good programming practice. Numeric values of the constants might change in subsequent ADO versions, causing unexpected results when upgrading applications to a new ADO release.




Special Edition Using Microsoft Office Access 2003
Special Edition Using Microsoft Office Access 2003
ISBN: 0789729520
EAN: 2147483647
Year: 2005
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net