Exploring Form Design View and VBA Class Modules

Designing forms and writing VBA code are advanced Access topics, but you can preview the topics covered by later chapters by following these steps:

  1. graphics/design_view.gif graphics/toolbox.gif With the Main Switchboard active, click the Design view button at the extreme left of the toolbar to open the Main Switchboard in Design view (see Figure 2.33). The Toolbox, which you use to add controls (text boxes, buttons, and the like) to forms, appears to the left of the Form Design window. If the Toolbox isn't open, click the Toolbox button on the Form Design toolbar.

    Figure 2.33. Open the Switchboard form in Design view.

    graphics/02fig33.gif

  2. graphics/properties_window.gif Press Ctrl+R to select the entire form and then click the toolbar's Properties button to open the Properties window. By default, the Properties window displays all the properties of the selected object in this case, the form.

  3. Click the Data tab to display only the data-related properties of the form (see Figure 2.34). The most important property is the Record Source, which specifies the Switchboard Items table as the table bound to the form. The Filter property specifies that the form obtains its data from the first record of the Switchboard Items table.

    Figure 2.34. The Data page of the Form properties sheet for the Switchboard form displays data-related property values.

    graphics/02fig34.gif

  4. Click to select the top button (under the C of Contact Management in the Design view of the form). The Properties window displays the properties of Command Button: Option1.

  5. Click the Event tab to display the Event properties of Option1 (see Figure 2.35). The=HandleButtonClick(1) value of the On Click event executes the HandleButtonClick VBA function when you click the button.

    Figure 2.35. The Event page displays a list of the events that Access forms can fire.

    graphics/02fig35.gif

  6. graphics/code.gif Click the Code button on the toolbar to display the Contacts Form_Switchboard (Code) window of the VBA editor. Page down until you see Private Function HandleButtonClick(intBtn As Integer), as shown in Figure 2.36. The Option1 command button calls this function to handle the On Click event. The (1) suffix of the event value is passed to the function as the value of the intBtn argument. Scroll through the code until you reach the End Function statement, which terminates the HandleButtonClick function.

    Figure 2.36. The VBA code editor displays the start of the HandleButtonClick event-handling function selected in Figure 2.35.

    graphics/02fig36.jpg

  7. graphics/subform.gif Close the VBA editor or press Alt+Tab to return to the Switchboard form and then click the Form view button to return the Switchboard form to its original state. (You might also need to close the Properties window.)



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