How to set a primary key?
A 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.
Alternatively, you can set a specific field as a primary key e.g. Employee No field.
- 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.
- Select the field you wish to be a primary key e.g. Employee Number.
- On the Design tab click the Primary Key icon in the Tools group.
- 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
- In Design View select the primary key field.
- Click the Primary Key icon in the Tools group to remove the primary key.