• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 3. Building a Simple Desktop and... > Exploring Form Design View and VBA C...

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. 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 3.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 3.33. Open the Switchboard form in Design view.

  2. 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 3.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 3.34. The Data page of the Form properties sheet for the Switchboard form displays data-related property values.

  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 3.35). The =HandleButtonClick(1) value of the On Click event executes the HandleButtonClick VBA function when you click the button.

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

  6. 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 3.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 3.36. The VBA code editor displays the HandleButtonClick event-handling function selected in Figure 3.35.

  7. 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.)

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint