TransferText - Append to existing text file

B

Brig Siton

Is there a way to have table or query exported out to a text file and APPEND
to what is already in the text file instead of overwrite?

Please advise.

Thank you.
 
D

Dirk Goldgar

Brig Siton said:
Is there a way to have table or query exported out to a text file and
APPEND to what is already in the text file instead of overwrite?


TransferText will always overwrite the target file. If you still want to
use TransferText, you can export to a temporary file, then use one of
several possible methods to append that temporary file to the final target
file. Those methods could include (1) using basic I/O commands to read the
temp output file and append its contents to the target file, (2) using the
FileSystemObject and its methods to do the same, or (3) shelling out to a
command-line command to copy-append the files.

Alternatively, you could use your own code to open a recordset on the
table/query, open the target file for append, and loop through the
recordset, formatting and writing output text lines.

Better than that, here is a link to a text-export class object written by
Dimitri Furman that supports appending to the target file:

http://www.mvps.org/access/modules/mdl0058.htm
Modules: Text Export Class

I haven't used it, but I'll bet it works just fine.
 
B

Brig Siton

Thank you very much.

Brig

Dirk Goldgar said:
TransferText will always overwrite the target file. If you still want to
use TransferText, you can export to a temporary file, then use one of
several possible methods to append that temporary file to the final target
file. Those methods could include (1) using basic I/O commands to read
the temp output file and append its contents to the target file, (2) using
the FileSystemObject and its methods to do the same, or (3) shelling out
to a command-line command to copy-append the files.

Alternatively, you could use your own code to open a recordset on the
table/query, open the target file for append, and loop through the
recordset, formatting and writing output text lines.

Better than that, here is a link to a text-export class object written by
Dimitri Furman that supports appending to the target file:

http://www.mvps.org/access/modules/mdl0058.htm
Modules: Text Export Class

I haven't used it, but I'll bet it works just fine.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top