Tip Archive
Importing Text Files into MS Access Tables
Sometimes it is necessary to import text files into Access databases. If the text file contains consistent delimiters such as commas, tabs, spaces, or semicolons between text areas that are to become the Access fields and carriage returns to indicate an end to each record, the importation process is fairly straightforward.
- Importing delimited text
- Open a Blank or Existing Access database
- Click on File in the dropdown menus
- Move the cursor over Get External Data and click on Import
- Select the appropriate Files of type at the bottom of the Import window (presumably Text Files with a .txt file extension)
- Select or enter the location and File name of the file to be imported
- Click OK
- Check the Delimited button on the first window of the Import Text Wizard
- Click Next
- Choose the delimiter that separates your fields
- If the First Row Contains Field Names check the box asking for that information, if not, leave it unchecked
- If an "or“ is used as a Text Qualifier click on it in the Text Qualifier box, otherwise leave it as {none}
- Click Next
- In the next Import Text Wizard window tell Access if you want to put the imported material In a New Table or an Existing Table (identify existing table) then click Next
- The next Import Text Wizard window allows you to name fields, declare field types, check for duplicates, and skip selected fields in the import process. Select any desired options, or just click on Next
- The next step in the Wizard allows you to set a primary key, let Access create a primary key, or import without a primary key. Select one and click Next
- The final window of the Wizard allows you to name the table you are importing into or accept the default name Access provides. Select one and click Finish
If the text file is not delimited, but the fields in the text strings are of a constant length or fixed width, and carriage returns indicate an end to each record, then it is still possible to import the text data into an Access table.
- Importing undelimited text (requires fixed field lengths in the text file)
- Carry out steps I. A through F above
- Check the Fixed Width button on the first window of the Import Text Wizard
- Click Advanced
- Type in a Field Name, set Data Type, position of starting digit of the field in the text string (in Start), number of digits in the length of the field (in Width), whether or not duplicate checking is to be done, and whether or not the field is to be skipped in the import
- Repeat Step II.D for each Field
- Click OK
- Click Next
- Check the accuracy of field breaks in the next Import Text Wizard window, correct as directed in the text box then click Next
- Follow steps I. M through P to complete the import of the text file into Access
Tip Archive