Microsoft Office Tutorials and References
In Depth Information
Chapter 3: Creating Smarter Forms
to see the rest of the values), of which one is selected. Figure 3-1 shows a
combo box and a list box.
Figure 3-1:
You can use
a combo
box (top) or
a list box
to choose
values from
a list.
List boxes take up more room on forms than combo boxes do, so they’re
used far less often. On the other hand, they allow you to see more values at
the same time. We explain in this chapter how to create both list and combo
boxes (the process is almost the same), but our examples concentrate on
combo boxes.
Before you create a combo or list box, consider the following questions:
Where will the values come from? The combo or list box displays a list
of values. Are the values stored in a table, or will you type them in the
control’s property sheet? If you use this list of values in any other control
on another form anywhere in your entire database, put the values in a
table — just a plain old table, with one field for the value and additional
fields if you store other facts about each value. Make sure that the table
has a primary key to uniquely identify each record. If your bookstore sells
three types of products, for example, these product codes need to be in
a table, because you’re sure to use them in lots of different forms and
reports. Don’t type them in the combo or list box’s property sheet.
If the values are stored in a table, which field (or fields) of the table
do you want to appear in the control? You can choose one or more
fields, but don’t choose too many; if you do, the list gets enormous. A
combo or list box for a StateOrProvince field, for example, can
display the two-letter state or province abbreviation, the full state or
province name, or both.
When the user of the form makes a choice from this control, what
happens to the selected information? Most forms are used for editing
the records in a table or query (the record source for the form). If the
purpose of the combo box or list box is to help the user enter a value in
a field, make a note of the field name. On the other hand, you may want
to use the combo or list box for another purpose, such as allowing the
user to find a record (as described in “Making a Find Box,” later in this
Search JabSto ::

Custom Search