How to set a primary key?

Setting a primary keyA primary key field is one that uniquely identifies each record in a table. Access does not allow duplicate primary key fields, so each one is unique. A primary key can be set while creating the table in the database or afterwards.

 

After you create and save the table in the database the Primary Key is automatically added to your table. It will have the Field Name – ID and the Data Type – AutoNumber.

As you enter data into the table the number 1 is added to the first record in the table, number 2 to the second record and so on.

Primary Key

Alternatively, you can set a specific field as a primary key e.g. Employee No field.

  1. In Design View – delete the existing primary key by selecting the field set as the primary key e.g. ID and press the delete key on the keyboard.
  2. Select the field you wish to be a primary key e.g. Employee Number.
  3. On the Design tab click the Primary Key icon in the Tools group.
  4. A key icon will appear next to the field Employee No.  The Employee No is now the primary key field.

 

To switch off the Primary Key

  1. In Design View select the primary key field.
  2. Click the Primary Key icon in the Tools group to remove the primary key.