MS Access

Using the Control Wizard

The Control Wizard (no relation to Merlin) helps you add powerful, interactive controls to your form, as shown in figure. Some examples include:

You can turn the Control Wizard

The Combo Box Wizard.

Two interactive controls added to a form using the .

Examples:

  • List and combo box controls that can look up values in a table and then display the corresponding record on a form.

  • Buttons that can open, print, or close tables, forms, queries, pages, and reports.

  • Subforms, subreports, and charts that display related data from different tables.

When you add a control using the Control Wizard, you are asked a series of questions about what you want the control to do. The Control Wizard then creates the control, making the appropriate property settings and even adding several lines of Visual Basic code to the control for you.

  1. Open the frmCustomers form in Design view.

    To use the Control Wizard, simply make sure that the Control Wizards button on the Toolbox is shaded orange, as shown in figure, and then add the control. The Control Wizard will appear anytime you try to create a list box, combo box, option group, button, chart, subreport, or subform.

  2. Make sure the Control Wizards button on the Toolbox is pressed in.

    The Control Wizard is so incredibly cool and useful that you are strongly recommended to always keep it on.

    If the Toolbox isn't displayed, click the Toolbox button on the Form Design toolbar.

    First let's add a combo box control to the form.

  3. Click the Combo Box button on the Toolbox.

    The mouse pointer changes to a indicating that you can click and drag a combo box control on the form.

  4. Place the pointer in the form header, about one inch to the right of the "Customers" label. Click and drag the pointer to the right about an inch and release the mouse button.

    Because the Control Wizard is on, the appears, as shown in figure. Each type of control will have its own Control Wizard and its own set of options. For this exercise, you want to select the third option.

  5. Select the Find a record on my form based on the value I selected in my combo box option and click Next.

    Next the Control Wizard asks which values you want to add to your combo box control

  6. Click the button three times to add the CustomerID, LastName and FirstName fields to the combo box and click Next.

    Next the Control Wizard asks how wide you want the columns in your combo box control and if you want to hide the key column. Everything looks okay here, so...

  7. Click Next.

    Finally, you are asked to give your combo box a name. You can accept the default name provided by the Control Wizard or you can provide your own name.

  8. Type Lookup Name and click Finish.

    Poof! The Control Wizard adds the combo box. Next let's add a command button that will print the current record when clicked.

  9. Click the Command Button button on the Toolbox and add a button to the right of the CustomerID text box by clicking and dragging.

    Because the Control Wizard is on, the Command Button Wizard appears. Command Buttons have lots of options that you can choose from, broken down by categories.

  10. Select Record Operations from the Categories list and select Print Record from the Actions list.

    This will make the command button print the current record when clicked.

  11. Click Next.

    Here you can specify the text or picture that will appear in the button.

  12. Click Finish.

    Access adds the command button to the form.

  13. Click the View button on the Form Design toolbar.

    Let's see how our new controls work.

  14. Select a name from the new Lookup Name combo box.

    Access finds and displays the record that you select from the combo box.

  15. Click the Close button to close the frmCustomers form and Yes to save.

Try experimenting and adding controls to your forms using the Control Wizard. You'll be amazed at how much you can accomplish without knowing any programming!

To create a list box or combo box:

  1. display the form in design view.

  2. click the toolbox button on the toolbar, if necessary, and make sure the control wizards button on the toolbox is selected.

  3. click the combo box or list box button on the toolbox.

  4. in the form window, click and drag where you want the control to appear.

  5. specify whether you want the control to get its values from a table or query, or if you want the control to find a record on the form.

  6. select the table that contains the fields you want to include in the list and click next.

  7. select the fields you want to appear in your list and click next.

  8. adjust the column widths, if necessary, and click next.

  9. if necessary, specify which column contains the value that will be stored and click next.

  10. specify whether access should merely display the value or display it in a field.

  11. enter a label and click finish.

by BrainBellupdated
Advertisement: