
create text file with header record
Alternatively, you could write a dummy header record before
writing the data, open that file later in binary mode for
modification, and modify the count in that dummy record.
Allen's method is simpler, perhaps, but this approach would
be faster if you have very many records.
I don't think there's a binary mode if you use the
FileSystemObject. I don't use it, anyway, except for demos,
because it requires the scripting runtime which many system
adminstrators disable, or search out and destroy, as a
security measure.
message
Quote:
> Simple way to program it:
> 1. Write the query out to a temp file.
> 2. Create the header string.
> 3. Open the real file, and write the header plus each line
from the temp
> file.
> DoCmd.TransferText acExportDelim, , "MyQuery", _
> strPath & strFileTemp, False
> 'Add the Header, and write to the real file.
> 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
> 'Delete the temp file.
> Kill strPath & strFileTemp
> --
> Allen Browne - Microsoft MVP (Most Valuable Professional)
> Allen Browne's Database And Training - Perth, Western
Australia.
> Tips for MS Access users - http://allenbrowne.com
> Reply to the newsgroup. (Email address has spurious
"_SpamTrap")
> > I have created a query to append to a table, written vb
to export the
> > table to a fixed width text file. Now I need to figure
out how to
> > 1) create the header record which includes a count of
the detail records
> > (I'm thinking a counter in a loop)
> > 2) -insert- (not append) this header in the first line
of the text file
> > 3) use access vb to ftp the header/detail file to the
recipient (anyone
> > doing anything like this?)
> > I am at a loss as to how to do these steps. Thank you
for any and all
> > hints/suggestions/links provided.
> > CAS