How to add lookup fields in a Microsoft Access table

Article translations Article translations
Article ID: 304462 - View products that this article applies to.
This article was previously published under Q304462
Novice: Requires knowledge of the user interface on single-user computers.

For a Microsoft Access 2000 version of this article, see 304463.
For a Microsoft Access 97 version of this article, see 304464.
Expand all | Collapse all

On This Page

SUMMARY

In Microsoft Access, you can add a field to a table to look up information in another table. You typically use this technique when you want to create relationships between tables. For example, perhaps you have a Products table with a Category field that looks up the category name from a Categories table. By using this technique, you can store the primary key value only in the Categories table, but display the more useful Category name.

This article shows you how to add lookup fields to a Microsoft Access table. First, it shows you how to use a wizard to add the lookup field, and then it shows you how to add the lookup field manually.

MORE INFORMATION

Use a wizard to create a lookup field

  1. Start Access.
  2. On the Help menu, click Sample Databases, and then click Northwind Sample Database. Close the Main Switchboard form when it appears.

    Note In Access 2007, click Sample in the Template Categories pane, click Northwind 2007, and then click Download.
  3. On the View menu, click Database Objects, and then click Tables.

    Note In Access 2007, in the Tables group on the Create tab, click Table Design.
  4. Double-click Create table in Design View to create a new table.

    Note In Access 2007, skip this step.
  5. Type EmployeeLookup in the first row under Field Name.
  6. In the Data Type column, select Lookup Wizard.
  7. On the first page of the Lookup Wizard, click to select the I want the lookup column to look up the values in a table or query check box, and then click Next.
  8. Click the Employees table in the list of tables, and then click Next.
  9. Double-click the EmployeeID field, the LastName field, and the FirstName field to add the fields to the list of selected fields, and then click Next two times.
  10. Make sure that the Hide key column check box is selected, and then click Next.
  11. Click Finish on the last page of the Lookup Wizard.
  12. Click Yes to save the table when you are prompted, and then name the table TestLookupWizard.
  13. Click Yes to add a primary key to the table when you are prompted.

    Notice that the wizard will create a relationship between the new table and the Employees table in the Northwind sample database.
  14. On the View menu, click Datasheet View.

    Note In Access 2007, open the table in the Datasheet View.
  15. Click the drop-down arrow in the EmployeeLookup field.

    Notice that two columns appear in the combo box.

Manually create a lookup field

  1. Start Access.
  2. On the Help menu, click Sample Databases, and then click Northwind Sample Database. Close the Main Switchboard form when it appears.

    Note In Access 2007, click Sample in the Template Categories pane, click Northwind 2007, and then click Download.
  3. On the View menu, click Database Objects, and then click Tables.

    Note In Access 2007, in the Tables group on the Create tab, click Table Design.
  4. Double-click Create table in Design View to create a new table.

    Note In Access 2007, skip this step.
  5. Type EmployeeLookup in the first row under Field Name.
  6. In the Data Type column, click Number.
  7. In the Field Properties window, click the Lookup tab.
  8. Iin the DisplayControl list, click Combo Box.
  9. Click in the RowSource property box, click the arrow that appears, click Employees in the list, and then click Build to open the Query Builder.
  10. Double-click the EmployeeID field, the LastName field, and the FirstName field to add the fields to the query grid.
  11. In the Close group on the Design tab, click Close to exit Query Builder.
  12. Click Yes when you are prompted to save changes to the SQL statement.
  13. Make sure that the BoundColumn property is set to 1.

    Note This property corresponds to the field in the row source that is saved in the field. In this example, the EmployeeLookup field stores the EmployeeID value from the Employees table.
  14. Change the value of the ColumnCount property to 3.

    Note This value represents the number of fields that are selected in the row source.
  15. Type 0";1";1" in the ColumnWidths box.

    Note The ColumnWidths property is a semicolon-delimited list of widths for each column in the row source. Set a column width to 0" if you want to hide the column.
  16. Type 2" in the ListWidth box.
  17. On the View menu, click Datasheet View.

    Note In Access 2007, open the table in the Datasheet View.
  18. Click Yes to save the table when you are prompted, and then name the table TestLookupWizard2.
  19. Click Yes to add a primary key to the table when you are prompted.
  20. Click the drop-down arrow in the EmployeeLookup field.

    Notice that two columns appear in the combo box.

Properties

Article ID: 304462 - Last Review: March 29, 2007 - Revision: 5.0
APPLIES TO
  • Microsoft Office Access 2007
  • Microsoft Office Access 2003
  • Microsoft Access 2002 Standard Edition
Keywords: 
kbinfo kbexpertisebeginner kbdesign kbdatabase kbhowto KB304462

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com