The list box contains rows of data, and is usually sized so that several rows are visible at all times. The rows can have one or more columns, which can appear with or without headings. If the list has more rows than can be displayed in the control, Access displays a scroll bar in the control. The user is limited to the choices given in the list box; it is not possible to type a value into a list box. A combo box also gives you the ability to enter a value that is not in the list.
In this way, the combo box control combines the features of a text box and a list box. Click the arrow to display the drop-down list. Click an option in the drop-down list. List boxes and combo boxes can be bound or unbound controls. These controls can look up values in a fixed list that you type yourself, or they can look up values in a table or query. To create a bound list box or combo box that looks up values in a table or query, make sure the form is based on a record source that includes a foreign key field or Lookup field.
This makes it possible to create the relationships that are needed to link the data in the list box or combo box to the data on the form. Create a list box or a combo box by using a wizard Right-click the form in the Navigation Pane, and then click Design View.
This procedure assumes that the form is bound to a table or query. Some of the steps will not apply if the form is unbound. To determine if the form is bound to a table or query, press F4 to display the property sheet. On the Data tab of the property sheet, the Record Source property box displays the table or query that the form is bound to. Click either the List Box tool or the Combo Box tool. On the form, click where you want to place the list box or combo box.
When the wizard asks how you want to get the values for the control, do one of the following: If you want to display a fixed list of values that will seldom change, click I will type in the values that I want. This creates an unbound control with an embedded macro that performs a find operation based on the value the user enters. Follow the instructions for specifying how the values will appear. If you chose one of the first two options on the first page of the wizard, the wizard asks what you want Access to do when you select a value.
Do one of the following: To create an unbound control, click Remember the value for later use. This means that Access will hold the selected value until the user changes it or closes the form, but it will not write the value to a table. To create a bound control, click Store that value in this field, and then select the field you want to bind the control to. Click Next and type a label for the control. This label will be displayed next to the control.
Create a list box or a combo box by adding a Lookup field to a form You can create a bound list box or combo box by adding a Lookup field to a form. Create a Lookup field in a table. The Lookup field you create can be either multivalued or contain a single value. For more information about creating Lookup fields, see the article Add or change a lookup field that lets you store multiple values.
Create a new form that is based on a record source that includes the Lookup field. For example, in the Navigation Pane, select a table or query that contains the Lookup field, and then on the Create tab, in the Forms group, click Form. Access automatically creates a combo box for the Lookup field. Add a list box or combo box to a form: In Design view, open a form that is based on a record source that includes the Lookup field.
Double-click the Lookup field, or drag the Lookup field from the Field List pane to the form. Access automatically creates a combo box bound to the field. To change a combo box to a list box or vice versa , right-click the control, click Change To on the shortcut menu, and then click the control type you want.
Create a list box or a combo box without using a wizard When you create a list box or combo box without using a wizard, you set many of the properties of the control yourself. If you want more information about a particular property, click the appropriate property box and press F1. Open a form in Design view. Click the List Box tool or the Combo Box tool. Click once inside the form to create a default-sized control, or click and drag until the control is the size you want.
With the control still selected, press F4 to open its property sheet. For more information about building a query, see the article Create a simple select query. Show a fixed list of values Value List Type a list of fixed values separated by semicolons ;. Show a list of fields from a table or query Field List In the drop-down list, select the table or query containing the field names that you want to appear in the list box or combo box.
If you want more than one column to appear in the control, click the Column Count property box and type the number of columns you want. Set the Column Widths property to adjust the widths of the columns. For more information about each property, place the cursor in the property box and then press F1.
If you want Access to store the value you select, click the Control Source property box and select the field to which you want to bind the list box or combo box. To edit the list of values, the Allow Value List Edits property for the list box or combo box must be set to Yes.
Edit a value list in Form view When your cursor enters a list box or combo box by clicking or tabbing to the box , a button appears below the list. Click the button to open the Edit List Items dialog box. Edit the list items, keeping each item on a separate line.
To select a default value for new records, click the drop-down arrow in the Default Value box, and then click the value you want.
Prevent the editing of the value list in Form view Right-click the form in the Navigation Pane and click Design view or Layout view. Click the control to select it, and then press F4 to display the property sheet. Specify a different form for editing the value list By default, Access provides a built-in form for the purpose of editing the value list.
If you have another form that you would prefer to use for this purpose, you can enter the name of the form in the List Items Edit Form property, as follows: Right-click the form in the Navigation Pane, and then click Design view or Layout view on the shortcut menu.
On the Data tab of the property sheet, click the drop-down arrow in the List Items Edit Form property box. Click the form you want to use for editing the value list. Customize a list box or a combo box With the form open in Design view, ensure that the list box or combo box is selected, and then press F4 to open the property sheet for the control.
Then, do one of the following: If you want to specify a different sort order, or if you have set the Row Source property of the control to a saved query, use the following procedure: Click the Data tab, and then click the Row Source property box.
On the Data tab of the property sheet, click to open the Query Builder. In the Sort row for the column you want to sort, specify the sort order you want.
Bind a column from a list box or combo box In the Bound Column property box of the list box or the combo box, specify a number that corresponds to the placement of the column in the list box or combo box. For example, type 1 to bind the first column in the list box or combo box to the underlying field specified in the Control Source property. Include hidden columns when you count columns. If you set the Bound Column property to 0, Access saves the list index instead of a value from one of the columns.
This is useful if you want to store a sequence of numbers instead of the list value. Hide a column in a list box or combo box on a form In the Column Widths property box, type 0 for the column or columns that you want to hide. For example, suppose you have a bound two-column combo box that has a 0.
The SupplierID Column can still be the bound column, even though it is hidden. In a combo box, the first visible column is displayed in the text box portion of the combo box when the list isn't displayed.
For example, the SupplierName column in the previous example would be displayed because the SupplierID column is hidden. Add column headings to a combo box on a form In the Column Heads property box, click Yes to display column headings. Headings in combo boxes appear only when the list is open. If the combo box or list box is based on a record source, Access uses the field names from the record source as the column headings. Turn off the fill-in-as-you-type feature for a combo box on a form In the Auto Expand property box, click No.
When the Auto Expand property is set to No, you must select a value from the list or type the entire value. Set the width of the list box portion of a combo box on a form In the List Width property box, enter the width that you want, using the current unit of measurement set in Windows Control Panel.
To use a unit of measurement other than the default, include a measurement indicator. For example, enter 2 cm. Make sure to leave enough space for a scroll bar. The list box portion of the combo box can be wider than the text box portion, but it cannot be narrower. The default setting Auto makes the list box the same width as the text box portion of the combo box. Set the maximum number of rows to display in a combo box on a form In the List Rows property box, enter a number.
If the actual number of rows exceeds the number specified in the List Rows property, a vertical scroll bar is displayed in the combo box. Limit combo box entries to items in the list portion of a combo box on a form In the Limit To List property box, click Yes. If the first column displayed in a combo box is not the bound column, Access limits the entries to the list even if the Limit To List property is set to No.
If the Limit To List property is set to No, when you enter an entry that isn't in the list, if the combo box is bound, the entry is stored in the underlying field, but it isn't added to the list.