Export to Existing text file via VBA

Hemish

Registered User.
Local time
Today, 06:31
Joined
Jan 20, 2005
Messages
65
Hi,

I have the below code which works fine.

DoCmd.TransferText acExportDelim, "ProductFile", "qryEportProductFile", "L:\Sales \ProductFile.txt"

But now I want to export code to an existing text file. So the data appended starts from a new line from on the existing text file.

Do you know how to append this in VBA please?
Path ="L:\Sales \ProductFile.txt"
File Name = “qryEportProductFile"
Thank you
 
In some cases (I don't know if VBA is one of them), the Open command has an "extend" option which opens a text file and places the insertion point after the last record so you can add new records to the end. I may be having a COBOL flashback though.

If that doesn't work, you need to work with two files. Open the original text file for input and open a new file for output. Loop through the input file and write all the records to the output file. Then write the new records to the output file.
 
Not just a flashback, Pat:-

Code:
Sub TestIt()
    Dim intFileOut As Integer

    intFileOut = FreeFile()
    
    Open "L:\Sales\ProductFile.txt" For Append As intFileOut

    Print #intFileOut, "Some Data"
    
    Close #intFileOut

End Sub

Chris.
 
Thank you for your help i will try this out in the next couple of days and get back
 

Users who are viewing this thread

Back
Top Bottom