Click here for great value web hosting.

 

HOME

ACCESS

EXCEL

WORD

OUTLOOK

POWERPOINT




Search for
 

help


 ALL ABOUT OFFICE

ACCESS

Creating a Primary Key

The primary key is a unique field or group of fields which is used by Access to index your data and to relate tables together quickly and efficiently.  The primary key for a particular table must be a field or set of fields which contain a unique value.  Access will prevent you from entering duplicate or null (blank) values in fields which are part of the primary key.

For our employees database we can fairly safely use a combination of first name, last name and date of birth as the primary key as it is highly unlikely that this will be duplicated.  Once this key has been defined, these three fields will have to be completed for every employee added to the database but this should not be a problem as these three fields should apply to everybody.

To create the primary key, click on the Tables section of the database window and choose the table you want to set a primary key for.  Click on the Design button and you will see the design view of your table which you used to create the fields.  Click on the grey shaded square at the left hand end of the row of the first field you want to include in your primary key, the whole row is now highlighted.  Now keep the Shift key held down and click the grey squares for any other fields you want to include in the primary key.  When all the rows you require are highlighted, click your right mouse button and choose Primary Key from the menu which appears as below.

You will now see a key symbol appear at the left hand edge of the rows you have selected, indicating that these fields form the primary key as below.

If one of your fields is not unique or is null (blank), you will not be able to include it in your primary key.  If you are not able to use an existing field as a primary key because none of them are unique, you can create an extra AutoNumber field as the primary key which will be automatically completed with an incremental unique number as you enter records in the database.

Click here to return to the Access index.

webmaster@allaboutoffice.co.uk