add combo box


Add a Combo Box with the Artists' Names

Here, we will add a combo box containing a list of all artists' names to the form. This will allow users to select artists by their name, rather than their ID. However, the form will still insert the ID into the Albums.ArtistId field.

Screenshot of the Form.

Add the Form Control

Open the form in Layout View.

Click the Combo Box icon from the Design tab on the Ribbon.

Now click the form in the location that you want the combo box to be inserted. The Combo Box Wizard will open

Before you click, as you hover your cursor over the form, Access will display a red line wherever you move the cursor, to help you see where the combo box will be inserted

Screenshot of the Combo Box Wizard.

The Combo Box Wizard: Select a source for the Values

As mentioned, clicking on the form automatically opens the Combo Box Wizard.

Select the first option: I want the combo box to get the values from another table or query and click Next >

Screenshot of the Combo Box Wizard.

Select a Table

Select Table: Artists and click Next >

Screenshot of the Combo Box Wizard.

Select Fields

Click >> to move both fields across to the right pane, then click Next >

Screenshot of the Combo Box Wizard.

Select Sort Order

This determines the order in which the items will appear in the list. We'll order them by the artists name.

Select ArtistName and Ascending, then click Next >

Screenshot of the Combo Box Wizard.

Column Width

Adjust the column width as desired then click Next >

Screenshot of the Combo Box Wizard.

Select where to store the Value

Click Store that value in this field: and select ArtistId

Then click Next >

This means that the ArtistId for the selected artist will be inserted into the Albums.ArtistId field.

So even though the user only selected the artist's name from the combo box, the ID is what's inserted into the table.

Screenshot of the Combo Box Wizard.

Combo Box Label

Type a label for the combo box and click Finish

Screenshot of the Combo Box Wizard.

The Combo Box

Access will close the wizard and you'll see the form with the new combo box.

         Delete the old Control

You have the option of keeping the ArtistId form control or removing it.

To delete the old control (and its label) click on each one while holding down the Shift key. Then right-click and select Delete from the contextual menu.

Test the Form/Combo Box

Go ahead and use the form to add new records to the database — now's your chance to add something from the last 25 years ;).

Screenshot of the Form.

Go to a New Record

Switch to Form View (either by clicking the View button on the Ribbon, or the Form View icon at the bottom right of the screen) and open a blank record.

To open a blank record, click the New (blank) record icon at the bottom of the screen.

Screenshot of the Form.Screenshot of the Form.

Enter Data

Enter data as a user would.

Tabbing or pressing Enter past the last field will submit the form and insert the contents into the table.

Note that, to display the date picker icon, you'll need to click inside the Release Date input control.


Comments

Popular posts from this blog

📚Gds-Tech 📚 EMS

vocab

spreadsheet in excel