Locked lesson.
About this lesson
Create a new table, populate it with information, and link it to the ticket table in preparation for creating a subform.
Exercise files
Download this lesson’s related exercise files.
8.01 setting-up-subforms---part-1 - Exercise.docx43.8 KB 8.01 setting-up-subforms---part-1 - Exercise solution.docx
80.8 KB TechGurusTicketing20.accdb
824 KB TechGurusTicketing20 - Complete.accdb
880 KB FootprintsTravelTourImport.txt
1.7 KB RelatedTicketsImport.txt
2.1 KB
Quick reference
Setting Up Subforms - Part 1
Start the process of creating a subform. Create a table that holds related ticket information, import data, and link the new table to the ticket table.
When to use
Add a subform to a form to provide related data from a one-to-many relationship. This allows you to present many related records within a record.
Instructions
A subform is a form within a form. They help us display additional information. To create a subform, we first need to create a table that contains the subform information, then create a subform and finally add the subform to the main form.
In our example, we are going to create a subform that shows related tickets. We are then going to add the subform to 'frmTicketMaintenance'.
Related Tickets Text File
First, let's review the information we will be using for the subform.
- Open 'RelatedTicketsImport.txt'.
- Review the information.
Creating a Table
- From the Create tab, in the Tables group, click Table Design.
- Add the following fields:
- RelatedTicketNumber (Data Type=Number)
- TicketNumber (Data Type=Number)
- DateLogged (Data Type=Date/Time)
- Charge (Date Type=Currency)
- SLA (Date Type=Number)
- Check the Field Properties for each field.
- Select the ‘RelatedTicketNumber’ and the ‘TicketNumber’ field and from the Table Design tab, in the Tools group, click Primary Key.
- Name the table ‘tblRelatedTickets’.
Import Your Information
We now need to add some data to the table.
- From the External Data tab, in the Import & Link group, select New Data Source.
- Select From File and Text File.
- Click Browse and select the file ‘RelatedTicketsImport.txt’.
- Append it to ‘tblRelatedTickets’.
- Click Next.
- Select Delimited.
- Click Next.
- Select Tab and First Rows Contains Field Names.
- Click Next.
- Click Finish and Close.
Relationships
- From the Database Tools tab, in the Relationships group, click Relationships.
- From the Add Tables pane, select ‘tblRelatedTickets’ and click Add Selected Tables.
- Drag the ‘TicketNumber’ field from ‘tblTicket’ to the ‘TicketNumber’ field in ‘tblRelatedTickets’.
- Select Enforce Referential Integrity.
- Click Create.
Lesson notes are only available for subscribers.