MICROSOFT ACCESS TABLES Create a New Table... 1 Design View... Datasheet View... 5 Table Tools in Datasheet View... 6 Sorting and Filtering Data... 8 Import and Export Data... 10 Relationships... 11 Relationship Errors... 14 University of Roehampton May 011 IT User Services
Create a New Table 1. Tables can be created from the Create ribbon, and then selecting one of the tool icons in the Tables group. 1. Tables can be imported from an Excel file or Text file. Open the External Data ribbon, and then select one of the tool icons in Import group. 1
Create a Table in Design View 1. Open the Create ribbon, and then select the Table Design tool from the Tables group. 1. A generic table will appear in the Detail Pane and a Tables Tools ribbon will appear with a Design sub-tab. There are various design tools available on it: Properties Insert Rows Delete Rows Indexes Primary Key Ribbon Tabs Detail Pane Navigation Pane 3 3. First type in the different field names for your data and accept the default data type ( text ).
4. In the Data Type box, there is a drop-down menu which allows you to select the correct data type. 4 5. After you select the correct data type, each field will have a number of general field properties, such as, Field Size, Required, Allow Zero Length, Indexed, etc. You can accept the default setting, or you can click on the appropriate properties field and change it. 5 3
6. When you click on any of the property fields, an explanation will appear in the box to the right. 6 Property Description Property Fields 7. Select a field to act as a unique identifier for each record that you will enter ( usually a number ID field ), and then click the Primary Key tool located on the Design sub-tab. 7 Note A primary key is important for creating a relationship between tables, and it allows Access to understand that in whatever tables this key appears, the data from these different tables are all parts of one unique record. 4
Datasheet View 1. After you have added the field names in Design View you will need to switch to Datasheet View in order to enter your data. On the Design sub-tab, click the Datasheet View icon. 1. You will be prompt to save the table. 3. In Datasheet View, your table is opened in the Detail Pane; click in any field cell to add data. 3 5
Table Tools in Datasheet View 1. In Datasheet View there is a Table Tools ribbon with two sub-tabs containing various quickaction tools. The Fields sub-tab will allow you to insert (or delete) new fields and configure the data properties of the new fields. 1 3. To add a new field, first click on an existing field name to indicate where you want the new field to be inserted. 3. Go to the Add & Delete tool group and select the type of new field you want, such as, a text field, a number field, a currency field, etc. 4. The new field will be inserted to the right of the existing field and the generic name will be highlighted. Simply type in the name you want, and then tap the <Enter> key. 4 6
5. On the Fields sub-tab there is a Formatting tool group which allows you to format the data so that it all looks the same. 5 Notes As mentioned the Table Tools ribbon in Datasheet View are quick-action, one-click tools. All the same features exist in Design View and you could have selected them when you first created the table in Design View. To switch back to Design View, click the Design icon which is in the Views tool group on the Fields sub-tab. Design View icon 7
Sorting and Filtering Data 1. Open the table in Datasheet View and open the Home ribbon. You will find a Sort & Filter tool group. 1. Click in a cell with the data you want to sort by, and then click one of the two Sorting tools. 3. Click in a cell with the data you want to filter by, and then click the Filter by Selection tool. 3 4. A sub-menu will appear, and then select the filtering option you want. 4 8
5. There is a Filter by Form button at the right of each field name. Click it to open a sub-menu of filtering options. 5 6 6. By default the Select All option is ticked. You must un-tick it, and then tick the filter option you want instead. Note To select all your data again, you will need to open the sub-menu again and tick the Select All option, or click the Clear filter from option. 9
Import and Export Data 1. Open the External Data ribbon. 1. You can see there are a group of tools in Import & Link and another group in Export. Note Simply click the tool you want to use from either group. Access should open a step-by-step wizard of dialogue boxes to complete the procedure. As most people tend to use Excel, it will probably be the most common import tool you will use. 10
Relationships As mentioned earlier, creating a relationship between tables allows Access to understand that the data in different tables are all parts of one unique record. In a relationship database the data in each table is linked by a primary key. 1. Open the Database Tools ribbon, and click the Relationships tool 1. In the Relationship Tools ribbon on the Design sub-tab, click the Show Table tool. Relationships Pane 11
3. The Show Table dialogue box will appear in the Relationship Pane. Select the tables (or queries) you want, and then click the Add button. 4. Chose one table as the parent and the other as the child. Then click and drag the parent s ID field to the child s ID field ( in this case the Staff Details ID to the Treadmill Tests ID ). 1
5. The Edit Relationship dialogue box will appear, and you can verify the correct tables and fields have been properly selected. Parent column Child column 7 6 6. You can tick the Enforce Referential Integrity option. This ensures integrity between the two ID fields, that is, there are no duplicates or missing numbers. 7. You may, or may not, want to tick one ( or both ) of the Cascade options. Click the Create button when finished. 8. In the Relationship Pane the tables will now show a relationship line between the two fields. If you want to edit the relationship, then right-click on the relationship line. 8 13
9. The importance of relationship will become more evident when you want to query records from different tables. But for now, when you open a table in a relationship, there is an expand icon at the start of each record. If you click the icon, it will reveal the related records from the other table in the relationship. 9 Relationship Errors 1. A database engine could not lock table error indicates that the table is still opened in the Detail Pane, and it must be closed before a relationship can be created. 1 14
. A relationship must be on the same number error indicates that the two fields have different property settings. You will need to open each table and check both the Data Type setting ( see page 3 ) and the Field Size setting ( see page 4 ). For both tables these must be set to the same restrictions. 3. A Access can t create this relationship and enforce referential integrity error indicates that in the Child ID field there is a number that cannot be found in the Parent ID field. Usually someone has typed a wrong number in one of the records of the Child ID field. 3 15
4. An example of a relationship database 4 Further Help IT Helpdesk Library; Ground Floor helpdesk@roehampton.ac.uk Online Learning 4/7 Software Support http://studentzone.roehampton.ac.uk/softwaresupport Software Advisor Daniel Rukstelis d.rukstelis@roehampton.ac.uk 16