Home > Articles

  • Print
  • + Share This
This chapter is from the book

Specifying a Primary Key in Design View

AC07S-1.3.1

A primary key is one or more fields in a table that provide a unique identifier for every row. You use the primary key in other tables to refer back to the table with the primary key. In Design view, you can use the Primary Key button to assign or remove the primary key designation for the selected field or fields. When you create a new table in Datasheet view, Access automatically creates a primary key and assigns it the field name “ID” and the data type AutoNumber. When you create a table in Design view, you can specify more than one field as a primary key, known as a composite key, so you are responsible for determining the data type of the primary key. Whatever data type you choose, values for the primary key must be unique for each table record.

Specify a Primary Key

yellow_circle_1.gif In Design view, create a field that will be that table’s primary key, and then select an appropriate data type.

  • If you choose the AutoNumber data type, Access assigns a value to the primary key for a new record that is one more than the primary key in the previous record.
  • If you choose any other data type, such as Text, Number, or Date/Time, during data entry, you must enter a unique value in the appropriate format for the primary key of each new record.

yellow_circle_2.gif Click the row selector of that field.

  • To create more than one primary key, press and hold Ctrl, and then click the additional row selector for each field.

yellow_circle_3.gif Click the Primary Key button.

yellow_circle_4.gif To remove a primary key, delete any table relationships associated with the primary key, select the row selector for the Primary key, and then click the Primary Key button.

  • + Share This
  • 🔖 Save To Your Account