Manipulate external file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My application exports data to a plain text file but I would like to prepend
a single line of text to the start of the file after it has been exported.
The text is not a part of any table in my app and its purpose is so that
another application (an accounting package) can recognise the text in the
file. Can this be done from within Access?

Alternatively can I add the text to the data being exported, the data comes
from a union query.

Thanks in advance.
 
One way to do this is to export the file with a temporary name, and then
write the final file consisting of the header row and the rows from the temp
file.

This kind of thing:

DoCmd.TransferText acExportDelim, , qdf.Name, strPath & strFileTemp, False
Open strPath & strFileTemp For Input As #1
Open strPath & strFile For Output As #2
Print #2, strHeader
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, strTmp
Print #2, strTmp
Loop
Close #2
Close #1
Kill strPath & strFileTemp
 
Back
Top