Examining Project Class Module Members in Object Browser and Project Explorer

Each Form and Report object in the current database that has a class module appears in the Classes list when you select the project name of the current database in the Project/Library (upper) drop-down list of Object Browser. By default, the project name for an Access database is the file name of the database without a file extension; thus, the project name for Northwind.mdb is Northwind. The default <globals> object displays all the procedures in conventional Access modules of the current database in the right-hand Members Of '< globals>' list. These procedures also appear in Members Of 'ModuleName' entries for each module in the project.

Tip

graphics/code.gif

graphics/object_browser.gif To launch Object Browser, select a form or report in the Database window, click the Code button to display the class module for the form, and then press F2 or choose View, Object Browser.


graphics/object_browser.gif When you select a Form or Report object, items representing properties of the Form or Report object and each of the control objects added to the Form or Report object appear in the Members Of 'ObjectName' list. Each procedure also appears (in bold type) in the list. Figure 28.5 shows the list item for OpenForms function; the syntax required to call the function appears in the bottom pane. Object Browser adds the Public prefix to functions and subprocedures that aren't declared Private. If you double-click a subprocedure or function item, the editor window displays its code.

Figure 28.5. Selecting the OpenForms function in Object Browser displays a replica of its header in the bottom pane. If the function header doesn't include a scope prefix, Object Browser adds Public.

graphics/28fig05.gif

Note

VBA 6.0 lets you define your own classes and write custom class modules. Custom class modules give you the opportunity to define a set of properties and methods for the object class you create. Custom class modules appear in Object Browser's Classes list, and the properties and methods you define appear in the Members Of 'ObjectName' list. Writing custom class modules is beyond the scope of this book.


The default reference to the Microsoft Access 11.0 Object library (Msacc.olb) enables programming of Access-specific objects, such as the DoCmd object described in the preceding section. To display Access-specific objects, select Access in Object Browser's Project/Library list. Scroll to and select the DoCmd object to display a list of its methods (see Figure 28.6). Object Browser's bottom pane displays the required and optional arguments of the method.

Figure 28.6. The Access DoCmd object has many methods, but no properties. The TransferSQLDatab ase method lets you emulate the Tools, Database Utilities, Transfer Database menu command of Access Data Projects (ADP).

graphics/28fig06.jpg

graphics/access_2002_new_icon.gif

The Project Explorer window displays all Form and Report Microsoft Access Class Objects, plus modules that contain global code accessible to all class modules. Double-clicking a list item opens a new editor window. You can change the project name and add an optional project description by right-clicking the Project node and choosing ProjectName Properties to open the updated ProjectName - Project Properties window (see Figure 28.7). Independent (also called standalone) Class Objects have an Instancing property; Form and Report Class Objects don't have properties.

Figure 28.7. The General page of the Project Properties window lets you rename a project and add a description. The Protection page offers the option to hide your VBA code from others and password-protect the code.

graphics/28fig07.jpg



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