Import Text Files with Multiple Header Sections into Microsoft Access
Question details
Import trade records from a text file that contains general and trade-specific header sections.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Each trade record must include fixed values supplied by preceding header sections.
- Observed behavior
- The file cannot always be linked directly in its current layout because header values must be repeated for each resulting trade record.
Inspect a sample file to identify how general headers, trade-specific headers, and trade records are distinguished. List the destination Access fields and determine when each header value changes or should be cleared.
Restructure the text file before importing it into Access
Use a spreadsheet to create one complete row per trade when the file can be prepared manually.
Open the text file in Excel or another spreadsheet application. Use its text import options to select the correct delimiter or fixed-width layout.
Add columns for the general and trade-specific values required by the Access table. In each column, enter or calculate the applicable header value for every trade row, changing or clearing it when a new section requires it.
Copy the completed columns and use Paste Special > Values. Remove the separate header-section rows, leaving one field-name row followed by one complete row per trade.
Save the flat table as a CSV file. In Access, choose External Data > New Data Source > From File > Text File, select the CSV, and follow the import wizard to map its fields to a new or existing table.
Open the destination table in Access and compare record counts and representative trades with the source file, especially at section boundaries.

Write a custom Access VBA import routine
Use a coded importer for recurring files or layouts that are impractical to restructure by hand.
Prepare trade data in WPS Spreadsheets
WPS Office is a free, lightweight Office alternative with a familiar interface. Use WPS Spreadsheets to organize trade rows and carry header values into columns before exporting a flat file. It does not replace the Access import process or fix Access linking limitations.

Frequently Asked Questions
Why can't I link the original text file directly to Access?
The file has different kinds of rows: general headers, trade-specific headers, and trade records. A standard text import expects a consistent row structure, so the relevant header values may need to be added to each trade row first.
How do I import the prepared CSV into an existing Access table?
In Access, choose External Data > New Data Source > From File > Text File, select the CSV, and choose the option to append records to an existing table. Check the field mapping and data types in the wizard.
What should happen when a new header section starts?
Update the values carried into subsequent trade rows and clear any values that no longer apply. Check the first and last trade in each section against the source file.
Can WPS Office import the original file directly into an Access database?
WPS Spreadsheets can help prepare a flat CSV, but the CSV must still be imported through Access or a separate database routine.




