Locked lesson.
About this lesson
Import additional data from an Excel file and a Text File into Access and append it to the bottom of the Ticket table.
Exercise files
Download this lesson’s related exercise files.
4.01 importing-data-from-excel - Exercise.docx43.1 KB 4.01 importing-data-from-excel - Exercise solution.docx
117.3 KB TechGurusTicketing06.accdb
560 KB TechGurusTicketing06 - Complete.accdb
588 KB TechSalesTicketImport.xlsx
10.8 KB TechSalesTicketImport.txt
1 KB FootprintsTravelTourImport.txt
4.2 KB
Quick reference
Importing Data from an Excel spreadsheet and a Text File
Import data into Access from an Excel spreadsheet and a Text file and append it to the bottom of the Ticket table.
When to use
Import data from an external application when you want to add a large number of records quickly.
Instructions
Currently, we have two trips stored in the Ticket table. However, TechGurus have a lot more tickets that need to be added to the table. Instead of manually adding each record in datasheet view, we can save ourselves time by importing the records in bulk.
In our example, we have the full list of tickets stored in an Excel spreadsheet and a Text file.
Importing from an Excel Spreadsheet
- Download the file 'TechSalesTickets.xlsx' from the course files folder.
- Open the Excel file and review the column headings.
It's very important that the column headings in the Excel file match the field names in the Access table. If they do not match or there is a spelling discrepancy, the import will not work correctly as Access will not be able to map the fields.
- From the External Data tab, in the Import and Link group, select New Data Source.
- Hover the mouse over From File and select Excel from the menu.
The Get External Data window will open. This is a wizard-style dialog box that will guide us through the import process.
First, we need to select the Excel file to import.
- Click the Browse button and navigate to the folder where the Excel file is stored.
- Select the file and click Open.
Next, we need to specify where we want to import this data into the database. We want to append the new records to the end of the current table.
- Select Append a copy of the records to the table 'tblTicket'.
- Click OK.
- If prompted, select Yes to close the current table.
- From the Import Spreadsheet Wizard, click Next.
- Choose the table to import the records to, 'tblTicket'.
- Click Finish to import the records.
Importing from a Text File
Let's now look at how to import and append the same data from a text file.
- Download the file 'TechSalesTicketing.txt' from the course files folder.
- Open the text file in Notepad.
- Notice how each field is separated using a tab delimiter.
- Close the text file.
- From the External Data tab, in the Import and Link group, select New Data Source.
- Hover the mouse over From File and select Text File from the menu.
The Get External Data window will open. This is a wizard-style dialog box that will guide us through the import process.
First, we need to select the text file to import.
- Click the Browse button and navigate to the folder where the text file is stored.
- Select the file and click Open.
Next, we need to specify where we want to import this data into the database. We want to append the new records to the end of the current table.
- Select Append a copy of the records to the table 'tblTicket'.
- Click OK.
- If prompted, select Yes to close the current table.
The difference here is that we need to tell Access, which delimiter is used to separate each field in the text file.
- Select Delimited and click Next.
- Select Tab as the delimiter.
- Select First Row Contains Field Names.
- Click Next.
- Choose the table to import the records to, 'tblTicket'.
- Click Finish.
- Click Close to import the records.
Reopen the Ticket table to view the appended records.
Hints & tips
- Data stored in a text file could be separated by any type of delimiter. If the delimiter is not listed during the import process, choose 'Other' and type in the delimiter into the blank field.
- It is possible to save the import steps. This means that if we import another file, we can skip straight to the end of the process.
Lesson notes are only available for subscribers.