Locked lesson.
About this lesson
Make changes to the link table and understand the types of error messages that can occur.
Exercise files
Download this lesson’s related exercise files.
6.04 editing-the-link-table - Exercise.docx85.2 KB 6.04 editing-the-link-table - Exercise solution.docx
129.7 KB TechGurusTicketing12.accdb
712 KB TechGurusTicketing12 - Complete.accdb
724 KB Ticket_Example.txt
309 B
Quick reference
Editing the Link Table
Understand some issues that may come up when editing link tables and how to resolve them.
When to use
Edit a link table whenever you need to add new information or make a change.
Instructions
- Open the table 'tblTicketCompany' and review the fields.
First, let's create a drop-down list for the Companies List.
Troubleshooting Issues (Changing Data Types)
- Right-click on the tab and select Design View.
- From the 'Company' field, click the drop-down arrow in Data Type.
- Select Lookup Wizard from the list.
We will receive an error message as we cannot change the data type for fields that have existing relationships with fields in other tables.
Deleting Relationships
- From the Database Tools tab, in the Relationships group, select Relationships.
- Select the relationship between 'tblTicketCompany' and 'tblCompany'.
- Press Delete.
- Select the relationship between 'tblTicketCompany' and 'tblTicket'.
- Press Delete.
Editing the Link Tables
Let's create a drop-down to list the Companies.
- Open the table 'tblTicketCompany'.
- Right-click on the tab and select Design View.
- Change the Data Type for the 'Company' Field to Lookup Wizard.
- Select I want the lookup fields to get their values from another table or query.
- Click Next.
- Select Table: tblCompany.
- Click Next.
- Select the 'Company' field and click the chevron to move it to the Selected Fields area.
- Click Next.
- Sort by the 'Company' field.
- Click Next.
- Check the preview looks correct.
- Click Next.
- Select Enable Data Integrity and Restrict Delete.
- Click Finish.
- Save the table.
Let's refresh the Relationships window.
- Close down the Relationships window.
- From the Database Tools tab, in the Relationships group, select Relationships.
Notice that Access has automatically created a link between 'tblTicketCompany' and 'tblCompany'.
Creating a Drop-down List with Two Fields.
In order to add records to 'tblTicketCompany', it would be helpful to create another drop-down list to select the TicketID. However, it is quite hard to determine the Company simply based off of the TicketID. We can add the customer name as a reference point to make this easier.
- Open the table 'tblTicketCompany'.
- Right-click on the tab and select Design View.
- Change the Data Type for the 'TicketID' field to Lookup Wizard.
- Select I want the lookup fields to get their values from another table or query.
- Click Next.
- Select Table: tblTicket.
- Click Next.
- Select the 'TicketNumber' and the 'CustomerName' field and click the chevron to move them to the Selected Fields area.
- Click Next.
- Leave the sort order field blank.
- Click Next.
- Check the preview looks correct.
- Click Next.
- Select Enable Data Integrity and Restrict Delete.
- Click Finish.
- Save the table.
Let's refresh the Relationships window.
- Close down the Relationships window.
- From the Database Tools tab, in the Relationships group, select Relationships.
Notice that Access has automatically created a link between 'tblTicketCompany' and 'tblTicket'.
- Add records to 'tblTicketCompany'.
Adding Records to a Link Table
Now, let's add some records to the other link table, 'tblTicketStatus'.
- Double-click to open 'tblTicketStatus'.
We could use the same process and create drop-down lists to input the records. For this example, we will enter data manually.
If we refer to the 'Ticket_Example.txt' file, the ticket '123456' has a status of 'Active' and 'Pending'. Records can have multiple status's. As there are two, we need to ensure that we add both records to the table for this ticket.
- Type '1' into the 'TicketID' field.
- Type 'Active' into the 'Status' field.
- Type '1' into the 'TicketID' field.
- Type 'Pending' into the 'Status' field.
Carry on adding as many records as necessary for each ticket.
There is a much more efficient way of doing this using a form. We will look at this in later lessons.
Login to downloadLesson notes are only available for subscribers.