TransferText

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

Guest

Hello all,

DoCmd.TransferText acExportFixed, "ForecastSpec", "qrExport", "c:\testNew.txt"

I am using this command above and it works fine. The question I have is I
need to add a end line (A*T) to the file that I created. Is there a better
way to add this besides me re-opening the file like:

Open "c:\testNew.txt" For Input As #1

and reading/printing through until eof then adding the last line I need?
 
Mark said:
Hello all,

DoCmd.TransferText acExportFixed, "ForecastSpec", "qrExport",
"c:\testNew.txt"

I am using this command above and it works fine. The question I have
is I need to add a end line (A*T) to the file that I created. Is
there a better way to add this besides me re-opening the file like:

Open "c:\testNew.txt" For Input As #1

and reading/printing through until eof then adding the last line I
need?

How about opening it for Append and just writing the one line?
 
I got this to work, but again I hate having to run through the file again.
Is there an more efficient way at add "A*T" to the end of the text file
instead of reading through the whole file?
Here's the way the file looks

A*A 136281 P1 202
A*A 140285 P1 4433
A*A 115262 P1 4433
A*T

DoCmd.TransferText acExportFixed, "ForecastSpec", "qrExport", "c:\testNew.txt"

Open "c:\testNew.txt" For Input As #1
Open "C:\testComplete.txt" For Output As #2

Line Input #1, L

Do While Not EOF(1)
vStr = vStr + L & vbCrLf
Line Input #1, L
Loop
vStr = vStr + "A*T"
Print #2, vStr
Close #1
Close #2
 
Mark said:
I got this to work, but again I hate having to run through the file
again.
Is there an more efficient way at add "A*T" to the end of the text
file instead of reading through the whole file?
Here's the way the file looks

A*A 136281 P1 202
A*A 140285 P1 4433
A*A 115262 P1 4433
A*T

DoCmd.TransferText acExportFixed, "ForecastSpec", "qrExport",
"c:\testNew.txt"

Open "c:\testNew.txt" For Input As #1
Open "C:\testComplete.txt" For Output As #2

Line Input #1, L

Do While Not EOF(1)
vStr = vStr + L & vbCrLf
Line Input #1, L
Loop
vStr = vStr + "A*T"
Print #2, vStr
Close #1
Close #2

If you were going to do it that way, you could do it more efficiently
than that by reading in the whole file at one go:

vStr = Input(LOF(1), 1)

But did you see my earlier post about opening the file for Append?
 
I didn't see you post prior to writing mine. The append worked great, thanks!

DoCmd.TransferText acExportFixed, "ForecastSpec", "qrExport", "c:\testNew.txt"

Open "c:\testNew.txt" For Append As #1
Print #1, "A*T"
Close #1
 
I would also use the FreeFile Method to get a free FileNo rather than the
explicit #1.

Check Access VB Help on FreeFile.
 
Back
Top