Data Manipulation  «Prev  Next»

Primary Key - Exercise

Define Access Primary key

To designate the Company field in the Clients table the primary key, display the table in Design view, select the Clients field, and click the Primary key button on the toolbar.
Clients table
Clients table

To create a new autonumber field and define it as the primary key in the Projects table, begin by displaying the table in Design view
You can right-click the first row and choose Insert Rows to make a new row, or you can create the new field at the bottom of the list of fields and move it when you have defined it.
Name the field Project ID, choose AutoNumber as the data type and then click the Primary Key button on the toolbar.


Projects table
Projects table

You may want to see how the table looks in Datasheet view – the new field will have incremented numbers in it, you do not need to enter these numbers, Access does it for you automatically when you enter new records. If you completed this exercise successfully your Projects datasheet should look like this:

Projects table
Projects table