Appending two or more text files to the one file

N

Nadine

Hi,
I am trying to export out multiple files with different width settings to
one text file.
I am looking for the code to do this within access. Some one told me to
export the files and then shell to the windows copy command to concatenate
them , but I can not get this to work.

Thanks

Nadine
 
K

Klatuu

When you say different widths, I assume you mean different numbers of fields.
I also assume you will know which fields belong in which positions for each
of the files you want to export.
If my assumptions are correct, I would suggest you create a "transfer" table
that is set up to be the widest possible with all the necessary fields and
data types. Then, create an append query for each of the tables you want to
export that will append the data to the transfer table. The use the transfer
table in the TransferText method.
 
N

Nadine

Thank you for the reply. I have tried this but the problem is the
application that requires this file needs all the spaces removed ie the first
line in the file must be 80 Characters, the second line 80 Characters and the
third line 120 characters and the last line again is 80 characters. Hope this
gives you more of an insight as to what I need.

Thanks

Nadine
 
N

Nadine

thanks the code is as follows I hope it makes sense.

Option Compare Database
strFileOut = "C:\Direct Debits\Bankfile\master.txt"
Shell " COPY """ & strFile1 & """ + """ & strFile2 & """ """ & strFileOut &
"""", vbMinimizedNoFocus
 
K

Klatuu

That's not going to work. I was thinking in terms of opening a file, writing
the first 80 characters to that file, then the next 80, then the 120 and
closing the file.
 
N

Nadine

Thanks for that I will try and let you know.

Klatuu said:
That's not going to work. I was thinking in terms of opening a file, writing
the first 80 characters to that file, then the next 80, then the 120 and
closing the file.
 
N

Nadine

I can open a file but the file is not passing through with the code. Do I
need to write file and not line as follows:
Private Sub CreateAfile_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\testfile.txt", True)
a.Writeline ("C:\Direct Debits\strFile2.txt")
a.Close
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top