Lesson 11.1. Importing Information
Figure 11-1. Step 1 of the Import Text Wizard
Figure 11-2. Step 2 of the Import Text Wizard: Specify the text delimiter that separates the fields and the field names.
Figure 11-3. Step 4 of the Import Text Wizard: Specify the data type of the imported fields.
Figure 11-4. Step 5 of the Import Text Wizard: Specify a primary key.
People from different countries speak different languages, so naturally computer programs save files in different formats. Fortunately, just like some people can speak several languages, Access can read and write in other file formats. This lesson shows how to open one of the most common file formats in programsa tab-delimited text file in Microsoft Access.
Start Microsoft Access, if necessary, and open the Lesson 11 database.
Ready? Here's how to import a text file.
Select File Tip: Another way to import an external data file is to right-click any empty area of the Database window and select Import from the shortcut menu.
The appears. Normally, the Import dialog box only displays Microsoft Access databases. To import files created with other programs, you need to select the file type you want from the Files of type listin your case, text files.
Click the Files of type list arrow and select Text Files.
Access displays any text files in the current folder. Next you have to specify the text file that you want to open.
Browse to your Practice folder and double-click the Europe Expenses file.
The dialog box appears, as shown in Figure 11-1. You must specify how the information is stored in the text file. There are two options:
Delimited: Tabs, colons, semicolons, or other characters separate items in your text file. This is the most common (and default) option.
Fixed Width: All the items in your text file are the same length.
The Europe Expenses is a tab-delimited text filethat is, tabs separate its fieldsso you don't need to make any changes and can continue on to the next step.
The second step of the Import Text Wizard appears, as shown in Figure 11-2. Here you have to specify the delimiter character used to separate the fields in the text file. Surprisingly, Access is usually smart enough to figure out which character is used as the delimiter (usually a tab or comma). What is vitally important here is the "First Row Contains Field Names" check box. Hopefully, the data you're importing will include field names in the first row; otherwise, you will have to add the field names to the table yourself later. Luckily, the Europe Expenses text file does include field names in the first row, so we'll need to tell this to Access.
Check the First Row Contains Field Names check box.
Quotation marks or text qualifiers may surround some text entries and must be removed.
Click the Text Qualifier arrow, select " and click Next.
Next Access asks where you want to import the datato a new table or to an existing table that you select from a drop-down list. We want to store the imported data in a new table, so we don't have to make any changes here.
The next step of the Import Text Wizard allows you to specify the data types for the fields in the imported data, as shown in Figure 11-3. For example, you could specify that a particular field is a date or number field. Access is usually quite smart at guessing the data type for most fields, but you might want to double-check each imported field just to be sure. Simply click the field heading that you want to view and make any changes to the data type.
Next the Import Wizard asks if you want to add a primary key to the imported data, as shown in Figure 11-4. You can let Access add an AutoNumber primary field to the new table, use one of the imported fields as the primary (providing that it meets the criteria for primary fields), or not use a primary key.
Select the No primary key option and click Finish. Click OK to confirm the creation of the new table.
Access imports the text file and stores it in a new table called "Europe Expenses."
Table 11-1 below lists importable and .
Table 11-1. Importable and Exportable File Formats and Extensions
.wk4, .wk3, .fm3, .fmt, .all, .wk1, .wks
Text (both tab- and comma-delimited)
Dbase 2, 3, 4
TO IMPORT INFORMATION FROM ANOTHER FILE INTO ACCESS:
IN THE DATABASE WINDOW, SELECT FILE
SELECT THE TYPE OF FILE YOU WANT TO IMPORT FROM THE FILES OF TYPE LIST.
BROWSE TO THE APPROPRIATE DRIVE AND/OR FOLDER AND DOUBLE-CLICK THE FILE YOU WANT TO IMPORT.
FOLLOW THE ONSCREEN INSTRUCTIONS OF THE IMPORT TEXT WIZARD TO IMPORT THE DATA.