Alison Balteramp;#039;s Mastering Microsoft Office Access 1002003 [Electronic resources]

Alison Balter

نسخه متنی -صفحه : 544/ 84
نمايش فراداده

The Command Button Wizards: Programming Without Typing

With the Command Button Wizard, you can quickly and easily add functionality to your forms. It writes the code to perform more than 30 commonly required tasks. The tasks are separated into record navigation, record operations, form operations, report operations, application operations, and other miscellaneous tasks. The Command Button Wizard is automatically invoked when you add a command button with the Control Wizards tool selected. The first step of the Command Button Wizard is shown in Figure 5.33; here, you specify the category of activity and specific action you want the command button to perform. The subsequent wizard steps vary, depending on the category and action you select.

Figure 5.33. The first step of the Command Button Wizard.

Figure 5.34 shows the second step of the Command Button Wizard when the Form Operations category and Open Form action are selected in the first step. This step asks which form you want to open. After selecting a form and clicking Next, you're asked whether you want Access to open the form and find specific data to display, or whether you want the form to be opened and all records displayed. If you indicate that you want only specific records displayed, the dialog box shown in Figure 5.35 appears. This dialog box asks you to select fields relating the two forms. In the next step of the wizard, select text or a picture for the button. The final step of the wizard asks you to name the button.

Figure 5.34. The Command Button Wizard requesting the name of a form to open.

Figure 5.35. The Command Button Wizard asking for the fields that relate to each form.

What's surprising about the Command Button Wizard is how much it varies depending on the features you select. It allows you to add somewhat sophisticated functionality to your application without writing a single line of code. The code generated by the example just outlined is shown in Figure 5.36; it will make a lot more sense after you read the next couple of chapters. The advantage to the code generated by the Command Button Wizard is that it can be fully modified after it's written; this means that you can have Access do some of the dirty work for you, and then customize the work to your liking.

Figure 5.36. The code generated from the Command Button Wizard.