Discussion Locked

Import AscII file into Access

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I receive a name and address ASCII file each morning that I need to amend directly to a table with matching fields. (?FirstName?,?LastName?,?Address?,?City?,?State?,?zip?) I would like to accomplish this using a command button. Is there code that will allow me to do this?

7 replies

by donq

Of course there is. I assume your file arrives formatted and named the same every day??? and is stored in the same place every day???

Build, name and save an Access Table with a field structure identical to the incoming file. Create an append query using the daily file as the data source and your Access Table as the data target. Run the query every day, or build a form with a command button that runs the query.

If the new incoming file does not replace itsely automatically now, delete the new file after its contents are appended into a new table row every day.

by rwcrooks

If you want total control over the file, use an Import File Specification as an argument in the TRANSFER TEXT line of a macro. It is easy to use.

You can use the Import or Link Tables subcommand of the Get External Data command on the File menu to create a specification for a particular type of text file, such as a delimited text file that uses tabs to separate fields and has an MDY format for dates. When you click this command and select a type of text file to import, the Import Text Wizard runs. You can click the Advanced button in the wizard and define and save a specification in the dialog box that appears. You can then type the specification name in this argument whenever you want to import the same type of text file.

You can import delimited text files without typing a specification name for this argument. In this case, Microsoft Access uses the defaults from the wizard dialog box. You can use import/export specifications with HTML files, but the only part of the specification that applies is the specification for data type formatting.

by camcc591

Regarding you response to dong@trivergent.net: if "data.csv" is the daily file name, copy it into a standard location. In Access, create a link to the file at that location. Now create an append query based on the linked table. Each new day, copy the new file to the standard location (overwriting the old file) and the link-table will always find it. Run the append query and the new-day's records will be appended.

This discussion is closed to new replies.