Unit 3. Creating data tables (II)


We will fill in the grid defining each of the columns that compose the table:

We can define a field using the field builder which allows us to define fields from those in sample tables and are activated clicking on the button on the toolbar. For more information on the Field builder clic here .

Or we can define our own fields as explained next.

In the first row write the name of the first field, and by pressing the ENTER key we move to Data Type column, which by defect will be Text. Should we choose to change the type of data, click on the arrow of the drop down list and select another type.

For more information on different data types clic here

If you require more information on the Lookup Wizard… clic here .

When we choose a type for the data, at the bottom of the window, the Field properties section is activated so as to be able to indicate more characteristics for the field, we will look at these characteristics in detail in the next unit.

Press ENTER next to go to the third column of the grid.

It is not necessary to use this column as it only serves to write comments; usually a description of the field for the person who will be introducing data so as to know what to write, this comment will appear on the status bar on the data page.

Repeat the process until all the fields (columns) in the table have been defined.

The primary key

Before saving the table we need to assign a primary key.

The primary key provides a unique value for each row in the table and serves to identify the records in such a way that with this key we can be sure of not mistaking the record being identified. In a table we can not define more than one primary key, but we can have a multiple-field primary key (one primary key defined on several fields.

To assign a primary key to a field follow these instructions:

Click on the name of the field that will be the primary key.

Click on the Primary key button on the toolbar.

On the left of the field name will appear a key indicating to us that this field is the primary key of the table.

If we want to define a multiple-field primary key (based on various fields), hold down the Ctrl key and click on all those fields, then click on the button.

Important: Remember that a field or group of fields forming the primary key of a table cannot contain null values and neither have two rows in the table with the same value in the primary key fields.

When we try to insert a new row with values that infringe on these two rules the system will not allow us to create the row and will return an error.

Saving a table.

To save a table we need to:

Go to the File menu and select Save.

Or click on the Save button on the toolbar.

As our table does still not have a name, the following dialogue box will appear:

Write the name of the table.

Click on the OK button.

Note: If we have not assigned a primary key before saving the table, a dialogue box will appear advising us of this, and asking whether we would like Access to create one like this:

If we decide Yes, it will create a Autonumber field and will define it as the primary key.

If we decide No, the table is saved without a primary key, a primary key is convenient but not obligatory.

Closing a table.

To close a table, follow these steps:

Go to the File menu and select the Close option.

Or, clic in the Close button in the Database window.

To practise what you have learnt, you can perform the Step by step Exercise Tables Creation.