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

Chapter 2. Building Your First Access Ap... > 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 with the following steps:

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

Figure 2.39. The Switchboard form in Design view.

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.

Click the Data tab to display only the data-related properties of the form (see Figure 2.40). 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 (refer to Figure 2.17).

Figure 2.40. Data-related properties of the Switchboard form.

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.

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

Figure 2.41. Event properties of the Option1 command button.

Click the Code button to display the Form_Switchboard: Class Module window. Page down until you see Private Function HandleButtonClick(intBtn As Integer), as shown in Figure 2.42. The Option1 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.

Close the Class Module window to return to the Switchboard form, and then click the Form View button to return the Switchboard form to its original state.

Figure 2.42. Code for the HandlebuttonClick function that executes when you click a command button.



Not a subscriber?

Start A Free Trial

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