Setting the Primary Key in MS Access For MS Access 2000, 2002, 2003, 2007
Once you have a new Table in Access 2007 then you should be able to follow along. For the most part, this article will be dealing with 2000-2003. This Tutorial starts out just like the Basic Table Tutorial. The major difference is we will explore setting the Primary Key in MS Access.Go here for Setting the Primary Key in PDF Format
|
The Primary Key must contain unique data for each row in a table and can uniquely identify each record in said table. The Primary Key can not be Null. Before we can set the Primary Key in Access we need a Table. Assuming you have New Database aptly named db1.mdb by MS Access we will go through designing a basic table in Design View, and set a few of the data types. |
|
To design the table we will click "Create table in design View" this will bring up a new window. Default name will be Table1. This window will have 3 columns: Field Name, Data Type and Description. In the First column input your chosen field names. The following characters are not useable: Periods, Exclamation Points, Brackets, non-printable Characters and leading spaces. After you put in a field name (Mine is "CNT" for Count) you can click the empty box under Data Type. You will be presented with a list of available data types. I will select "AutoNumber" as this will be a useful data type. I can use Autonumber as a Unique Record Number and/or Primary Key. Alternatively, if you have a table already, Rt Click it and select Design View. You can then add or modify current fields.
To set the Primary key in Access all you have to do is Right click a field and select Primary key while in Design View. This field should contain no null values or duplicate data.
To select multiple fields as a Primary Key in MS Access you press and hold the CTRL key and then Left click each desired field. You then keep the CTRL Key pressed and right click a selected field and click Primary key. The values of the multiple fields must again not be null or contain duplicates. The multiple fields will function together as a Primary Key.
Once you have the Field or fields you want as Primary Key save your Table. MS Access will generate errors upon saving if they exist. Once you have saved the Table, close it. You should now be able to set Primary Keys as you see fit. Fields with Primary Keys will have a Key shape in front of them. These Fields will appear bold in the Query builder. In MS Access 2007 fields will have a key shape in the Query Builder as well.
For further help or suggestions go here: MS Access tutorials, Tables, Queries and later: Forms
You may post this tutorial on your website or in a forum. If you do please maintain a Link to Eraseve AP.
For further MS Access tutorials go here: MS Access tutorials
| Did you find what you were looking for? What would you suggest? mail@eraserve.com |





