Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Access files as txt with header and footer

Status
Not open for further replies.

AFKAFB

Programmer
Aug 22, 2005
26
US
Hi
I've a number of access tables that i need to save as pipe delimited text files.
That part is okay.
But now the recepients require the files to have a header and footer saying for example the date the file was created on one row, the number of records on the next and on the footer other stuff on different rows etc.
I guess i'll have to first save the file as txt, then run a procedure/macro that will open the file and insert the code.
How do i do this please?
Regards
chris
 
Typed NOT tested

dim f1 as long
dim f2 as long
dim f1name as string
dim f2name as string
dim header as string
dim footer as string
dim str as string

f1 = freefile
open f1name for input access read as f1
f2 = freefile
open f2name for output access write as f2

write #f2, header
do until eof(f1)
line input #f1, str
write #f2, str
loop
write #f2, footer

close #f1
close #f2

'then if necessary
kill f1name
name f2name, f1name

Hope this helps.

 
Hi
Thanks for the code.
Unfortunately i'm new to programming so i don't really understand the code.
To clarify i'll have already created the six files as txt files with names say fileA, fileB etc.
The header will read say
"P|QWERTY|dd/mm/yyyy|dd/mm/yyyy| and the footer will read
"G|1000"
Without being a real nuisance and wasting your time too much how would i then modify the code you've given to incorporate these file names and header/footer details.
regards
chris

 
I no longer have any interest in Access and will not therefore be monitoring or replying to threads in any Access forum.

Your requirements are very straightforward and anyone on the MVP list plus many others will be able to provide a solution for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top