Adding Controls to a Form


Every form has three basic sections: Form Header, Detail, and Form Footer. When you use a wizard to create a form, the wizard adds a set of controls for each field that you select from the underlying table to the Detail section and leaves the Form Header and Form Footer sections blank. Because these sections are empty, Access collapses them, but you can size all the sections by dragging their selectors . Although labels and text box controls are perhaps the most common controls found in forms, you can also enhance your forms with many other types of controls. For example, you can add groups of option buttons , check boxes, and list boxes to present people with choices instead of making them type entries in text boxes.

The most popular controls are stored in the Toolbox. Clicking the More Controls button displays a list of all the other controls on your computer. The controls displayed when you click the More Controls button are not necessarily associated with Access or even with another Microsoft Office program. The list includes every control that any program has installed and registered on your computer.

Important  

Some controls, such as the Calendar Control, can be very useful. Others might do nothing when you add them to a form, or might do something unexpected and not entirely pleasant. If you feel like experimenting, don t do so in an important database.

In this exercise, you will add a graphic and a caption to the Form Header section of the Customers form from the GardenCo database. You will also replace the Country text box control in the Detail section with a combo box control.

USE the GardenCo database in the practice file folder for this topic. This practice file is located in the  My Documents\Microsoft Press\Office 2003 SBS\Forms\Controls folder and can also be accessed byclicking Start/All Programs/Microsoft Press/Microsoft Office System 2003 Step by Step .

OPEN the GardenCo database and acknowledge the safety warning, if necessary.

  1. Open the Customers form in Design view.

  2. Point to the horizontal line between the Form Header section selector and the Detail section selector, and when the pointer changes to a double-headed arrow, drag the Detail section selector down a little over an inch.

    click to expand
  3. If the Toolbox isn t displayed, click the Toolbox button on the Form Design toolbar.

    You can also open the View menu and select the Toolbox check box. To keep the Toolbox open but out of the way, you can drag it off to the side, and dock it on one edge of the screen.

  4. To get an idea of the controls that are available, move the pointer over the buttonsin the Toolbox, pausing just long enough to display each button s ScreenTip.

  5. Click the Image control in the Toolbox, and then drag a rectangle about 1 inch high and 3 inches wide at the left end of the Form Header section.

    When you release the mouse button, Access displays the Insert Picture dialog box, in which you can select an image to insert in the control.

  6. Navigate to the My Documents\Microsoft Press\Office System 2003 SBS\Forms\Controls folder, and double-click tgc_logo2 . (If you don t see this file listed, change the Files of type setting to Graphics Files .)

    The Garden Company logo appears inside the image control.

    click to expand
    Tip  

    If the control isn t large enough, the image is cropped. You can enlarge the control to display the entire image. (You might also have to enlarge the Form Header section.)

  7. To add a caption to the header, click the Label control in the Toolbox, and then drag another rectangle in the header section.

    Access inserts a label control containing the insertion point, ready for you to enter a caption.

  8. Type the caption Customers , and press [ENTER].

    The Customers label takes on the formatting of the other labels.

  9. With the Customers label selected, press the [F4] key to display the Properties dialog box.

  10. Change the Font Size property to 18 , and change the Text Align property to Center . Then close the Properties dialog box.

  11. On the Format menu, point to Size , and then click To Fit .

  12. Adjust the size and position of the two controls you added so that they areside-by-side.

    click to expand
  13. If the Control Wizards button is active (orange) in the toolbox, click it to deactivate it.

    With the Control Wizards button turned off, you can create a control with all the default settings without having to work through the wizard s pages.

  14. Insert a combo box in the Details section by clicking the Combo Box control in the Toolbox and then dragging a rectangle just below the current Country text box.

    When you release the mouse button, Access displays a combo box control, whichis unbound (not attached to a field in the Customers table).

    Troubleshooting  

    Access provides a number for each control as it is created, so don t be concerned if the number displayed in your control is different from what you see in the graphics in this book.

  15. Copy the formatting of the Country text box to the new combo box control by clicking the Country text box, clicking the Format Painter button on the Form Design toolbar, and then clicking the combo box control.

    Both the combo box control and its label take on the new formatting.

  16. Right-click the combo box and click Properties on the shortcut menu to display the Properties dialog box.

  17. Click the Data tab, set the Control Source property to Country , and then type the following in the Row Source box:

     SELECT DISTINCT Customers.Country FROM Customers; 

    (Note that there is no space between Customers and Country; there is only a period. There is also a semi- colon at the end of the text.)

    This line is a query that extracts one example of every country in the Country field of the Customers table and displays the results as a list when you click the box s down arrow.

    (You might have to widen the Properties dialog box to display the whole query.)

    click to expand
    Tip  

    If you need to add a new customer from a country that is not in the list, you can type the new country s name in the combo box. After the record is added to the database, that country shows up when the combo box list is displayed.

  18. If necessary, set the Row Source Type to Table/Query .

  19. Click the label to the left of the combo box (if necessary, drag the Properties dialog box to see the combo box label). Then click the dialog box s Format tab, change the caption to Country , and close the dialog box.

  20. Delete the original Country text box and its label, and move the new combo box and label into their place, resizing them as needed.

  21. Click the View button to see your form.

    click to expand
  22. Scroll through a couple of records, and display the combo box s list to see how you can select a country.

  23. You don t need the record selector the gray bar along the left edge of the form ” so return to Design view, and display the Properties dialog box for the entire form by clicking the Form selector (the box at the junction of the horizontal and vertical rulers) and pressing [F4]. Then on the Format tab, change Record Selectors to No . While you re at it, change Scroll Bars to Neither . Then close the Properties dialog box.

  24. Save the form s new design, and switch to Form view for a final look.

  25. Close the form.

CLOSE the GardenCo database.




Microsoft Office 2003 Step by Step
MicrosoftВ® Office ExcelВ® 2003 Step by Step (Step By Step (Microsoft))
ISBN: 0735615187
EAN: 2147483647
Year: 2005
Pages: 350
Authors: Curtis Frye

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net