By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,773 Members | 2,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,773 IT Pros & Developers. It's quick & easy.

Appending Text file with a header record

P: n/a
I have a data application in a2k that I need to create two fixed width
text files and then combine them to a single file The first file is
header information and the second is transaction data. I have tried
and tried but just cant seem to get this right, I am using Queries to
created my export files with specifications which works fine, I get
stumped with the appending the header to my transaction file. What I
have so far looks like this .. What I wind up in my file is,

1 2003100713250020441007
"c:\Trans.Txt"

What I need to know is how to declare the c:\trans.txt so it will
append data and not the string

Any help would be great!

Thanks

Michael

+++++++++++++++++++++++++++++++++++++++++++++++++

Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String

strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"

'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1

Open strPath For Append As #1
Write #1, strPath1
Close #1

End sub
Nov 12 '05 #1
Share this Question
Share on Google+
16 Replies


P: n/a
The variable strPath1 is holding the name and path of the file, not the file itself, so
that is what is being appended. To append the data from the file, you will need to open
the file and use a Get statement to read the file and then append that data. You could use
a Do loop to run the read/append until EOF.

In the second TransferText call, what would happen if instead acExportFixed you used
acExportMerge, I don't see a good explanation of what each of these constants do.

--
Wayne Morgan
"Michael" <Mi******@HotMail.Com> wrote in message
news:43**************************@posting.google.c om...
I have a data application in a2k that I need to create two fixed width
text files and then combine them to a single file The first file is
header information and the second is transaction data. I have tried
and tried but just cant seem to get this right, I am using Queries to
created my export files with specifications which works fine, I get
stumped with the appending the header to my transaction file. What I
have so far looks like this .. What I wind up in my file is,

1 2003100713250020441007
"c:\Trans.Txt"

What I need to know is how to declare the c:\trans.txt so it will
append data and not the string

Any help would be great!

Thanks

Michael

+++++++++++++++++++++++++++++++++++++++++++++++++

Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String

strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"

'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1

Open strPath For Append As #1
Write #1, strPath1
Close #1

End sub

Nov 12 '05 #2

P: n/a
Mi******@HotMail.Com (Michael) wrote in message news:<43**************************@posting.google. com>...
I have a data application in a2k that I need to create two fixed width
text files and then combine them to a single file The first file is
header information and the second is transaction data. I have tried
and tried but just cant seem to get this right, I am using Queries to
created my export files with specifications which works fine, I get
stumped with the appending the header to my transaction file. What I
have so far looks like this .. What I wind up in my file is,

1 2003100713250020441007
"c:\Trans.Txt"

What I need to know is how to declare the c:\trans.txt so it will
append data and not the string


I think the problem is that you may need to output the two queries to
text first. Then you can open one for append and the other for read.
Read each line of the first and write it to the second. then you
should be off an running... I'm kinda wondering if you can't use
SPACE(intSpaces) to create your own delimited text file, because then
you can just open a text file, loop through the records in your
query's recordset, write the records to the file, close the first
query, open the second, repeat the output stuff, and then append the
path or whatever just using a write statement... I think this is just
a limitation of the TransferText method - it assumes one output file
per object.
Nov 12 '05 #3

P: n/a
What would happen if your output query was a Union query, combining both outputs into one
query?

--
Wayne Morgan
Nov 12 '05 #4

P: n/a
Wayne,

Your first idea is exactly what I need to do, though I am unclear how
to write the code to accomplish this. I have the two files outputting
correctly, I just need to append the first (header.txt) to the second
(trans.txt) Do you think you could provide an example?

Thanks for your help,

Michael
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<hO******************@newssvr32.news.prodigy. com>...
The variable strPath1 is holding the name and path of the file, not the file itself, so
that is what is being appended. To append the data from the file, you will need to open
the file and use a Get statement to read the file and then append that data. You could use
a Do loop to run the read/append until EOF.

In the second TransferText call, what would happen if instead acExportFixed you used
acExportMerge, I don't see a good explanation of what each of these constants do.

--
Wayne Morgan
"Michael" <Mi******@HotMail.Com> wrote in message
news:43**************************@posting.google.c om...
I have a data application in a2k that I need to create two fixed width
text files and then combine them to a single file The first file is
header information and the second is transaction data. I have tried
and tried but just cant seem to get this right, I am using Queries to
created my export files with specifications which works fine, I get
stumped with the appending the header to my transaction file. What I
have so far looks like this .. What I wind up in my file is,

1 2003100713250020441007
"c:\Trans.Txt"

What I need to know is how to declare the c:\trans.txt so it will
append data and not the string

Any help would be great!

Thanks

Michael

+++++++++++++++++++++++++++++++++++++++++++++++++

Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String

strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"

'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1

Open strPath For Append As #1
Write #1, strPath1
Close #1

End sub

Nov 12 '05 #5

P: n/a
Try this, some of it will depend on the way your data is formatted. This can be adjusted
to read specific record lengths, put quotes around text or not put quotes (use Print
instead of Write), etc. I currently have it reading one line at a time.
Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String
Dim strData As String

strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"

'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1
Open strPath1 For Append Access Write As #1
Open strPath2 For Binary Access Read As #2

Do
Line Input #2, strData
Write #1, strData
Loop Until EOF(2)

Close #1
Close #2

End sub
--
Wayne Morgan
"Michael" <Mi******@HotMail.Com> wrote in message
news:43**************************@posting.google.c om...
Wayne,

Your first idea is exactly what I need to do, though I am unclear how
to write the code to accomplish this. I have the two files outputting
correctly, I just need to append the first (header.txt) to the second
(trans.txt) Do you think you could provide an example?

Nov 12 '05 #6

P: n/a
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<Ua******************@newssvr31.news.prodigy. com>...
What would happen if your output query was a Union query, combining both outputs into one
query?


If I create a Join Query the Header shows up in every Record. I need
the Header to appear at the top of the text file and also a Trailer at
t he bottom of the file.
Nov 12 '05 #7

P: n/a
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++
Wayne,

This seems to work, however I am getting a Run Time error '62' Imput
Past end of file, and it is putting quotes around my Transactions in
the merged file. Below is a sample of the output and the finished
code I am using.

Thanks again for all your help!

This is a sample of the out put, which is perfect except for the
quotes

1 2003100713250020441007
"OHD773050105220030927"
"OHD773051105220030927"
"OHD773052105220030927"

This is the finished code ..

Private Sub Command0_Click()
Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String
Dim strData As String

strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"
'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1

Open strPath For Append Access Write As #1
Open strPath1 For Binary Access Read As #2

Do
Line Input #2, strData
Write #1, strData
Loop Until EOF(2)

Close #1
Close #2
End Sub

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<VE*****************@newssvr17.news.prodigy.c om>...
Try this, some of it will depend on the way your data is formatted. This can be adjusted
to read specific record lengths, put quotes around text or not put quotes (use Print
instead of Write), etc. I currently have it reading one line at a time.
Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String
Dim strData As String

strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"

'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1
Open strPath1 For Append Access Write As #1
Open strPath2 For Binary Access Read As #2

Do
Line Input #2, strData
Write #1, strData
Loop Until EOF(2)

Close #1
Close #2

End sub
--
Wayne Morgan
"Michael" <Mi******@HotMail.Com> wrote in message
news:43**************************@posting.google.c om...
Wayne,

Your first idea is exactly what I need to do, though I am unclear how
to write the code to accomplish this. I have the two files outputting
correctly, I just need to append the first (header.txt) to the second
(trans.txt) Do you think you could provide an example?

Nov 12 '05 #8

P: n/a
Mi******@HotMail.Com (Michael) wrote in message news:<43**************************@posting.google. com>...
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++
Wayne,

This seems to work, however I am getting a Run Time error '62' Imput
Past end of file, and it is putting quotes around my Transactions in
the merged file. Below is a sample of the output and the finished
code I am using.

Thanks again for all your help!

This is a sample of the out put, which is perfect except for the
quotes

1 2003100713250020441007
"OHD773050105220030927"
"OHD773051105220030927"
"OHD773052105220030927"

This is the finished code ..

Private Sub Command0_Click()
Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String
Dim strData As String

strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"
'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1

Open strPath For Append Access Write As #1
Open strPath1 For Binary Access Read As #2

Do
Line Input #2, strData
Write #1, strData
Loop Until EOF(2)

Close #1
Close #2
End Sub

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++


Do Until EOF(2)
Line Input #2, strData
Write #1, strData
Loop

Close #1
Close #2

You just need to test for EOF first, I think. Of course, you have to
make sure then that you get the last record in textfile #1 into #2.
Nov 12 '05 #9

P: n/a
I don't know how to get rid of the quotes, I had to get this far through trial and error
and reading the not so informative help file. Perhaps, if you seek to the end of file #1
then do a Binary write to the file?

--
Wayne Morgan
"Michael" <Mi******@HotMail.Com> wrote in message
news:43**************************@posting.google.c om...
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++
Wayne,

This seems to work, however I am getting a Run Time error '62' Imput
Past end of file, and it is putting quotes around my Transactions in
the merged file. Below is a sample of the output and the finished
code I am using.

Thanks again for all your help!

This is a sample of the out put, which is perfect except for the
quotes

1 2003100713250020441007
"OHD773050105220030927"
"OHD773051105220030927"
"OHD773052105220030927"

This is the finished code ..

Private Sub Command0_Click()
Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String
Dim strData As String

strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"
'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1

Open strPath For Append Access Write As #1
Open strPath1 For Binary Access Read As #2

Do
Line Input #2, strData
Write #1, strData
Loop Until EOF(2)

Close #1
Close #2
End Sub

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++
"Wayne Morgan" <co***************************@hotmail.com> wrote in message

news:<VE*****************@newssvr17.news.prodigy.c om>...
Try this, some of it will depend on the way your data is formatted. This can be adjusted to read specific record lengths, put quotes around text or not put quotes (use Print
instead of Write), etc. I currently have it reading one line at a time.
Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String
Dim strData As String

strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"

'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1
Open strPath1 For Append Access Write As #1
Open strPath2 For Binary Access Read As #2

Do
Line Input #2, strData
Write #1, strData
Loop Until EOF(2)

Close #1
Close #2

End sub
--
Wayne Morgan
"Michael" <Mi******@HotMail.Com> wrote in message
news:43**************************@posting.google.c om...
Wayne,

Your first idea is exactly what I need to do, though I am unclear how
to write the code to accomplish this. I have the two files outputting
correctly, I just need to append the first (header.txt) to the second
(trans.txt) Do you think you could provide an example?

Nov 12 '05 #10

P: n/a
I tried using the Do Until EOF but I get the same results. Funny
though I get my file correctly now or as soon as I reset after my
error I have a correctly formated file. But I still get a Run Time
Error Input past end of file on the last part of this routine. Anyone
have any ideas? I've added a second pass though to add a trailer file
to this and thats what's failing.

Thanks again to all!

Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strThirdQuery As String
Dim strPath As String
Dim strPath1 As String
Dim strPath2 As String
Dim strData As String
strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strPath2 = "c:\Trailer.Txt" 'Trailer file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"
strThirdQuery = "QryTrailer"
'Output Transaction Header c:\Header.txt
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions c:\Trans.Txt
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1
'OutPut Transaction Trailer c:\Trailer.Txt
DoCmd.TransferText acExportFixed, "EE2", strThirdQuery, strPath2
Open strPath1 For Append Access Write As #2 ' Transactions
Open strPath2 For Binary Access Read As #3 ' Trailer

'Merge c:\Trans.Txt with C:\Trans.Txt This part works

Do
Line Input #3, strData
Print #2, strData
Loop Until EOF(2)

Close #2
Close #3

Open strPath1 For Binary Access Read As #1 ' Transactions
Open strPath For Append Access Write As #4 ' Header

'Merge C:\Trans.Txt with C:\Header.Txt
'This part fails with the Input past end of file error

Do Until EOF(1)
Line Input #1, strData '<< Error here
Print #4, strData
Loop 'While EOF(1) 'Until EOF(1)

Close #1
Close #4
End Sub

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++

Do Until EOF(2)
Line Input #2, strData
Write #1, strData
Loop

Close #1
Close #2

You just need to test for EOF first, I think. Of course, you have to
make sure then that you get the last record in textfile #1 into #2.

Nov 12 '05 #11

P: n/a
I tried using the Do Until EOF but I get the same results. Funny
though I get my file correctly now or as soon as I reset after my
error I have a correctly formated file. But I still get a Run Time
Error Input past end of file on the last part of this routine. Anyone
have any ideas? I've added a second pass though to add a trailer file
to this and thats what's failing.

Thanks again to all!

Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strThirdQuery As String
Dim strPath As String
Dim strPath1 As String
Dim strPath2 As String
Dim strData As String
strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strPath2 = "c:\Trailer.Txt" 'Trailer file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"
strThirdQuery = "QryTrailer"
'Output Transaction Header c:\Header.txt
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions c:\Trans.Txt
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1
'OutPut Transaction Trailer c:\Trailer.Txt
DoCmd.TransferText acExportFixed, "EE2", strThirdQuery, strPath2
Open strPath1 For Append Access Write As #2 ' Transactions
Open strPath2 For Binary Access Read As #3 ' Trailer

'Merge c:\Trans.Txt with C:\Trans.Txt This part works

Do
Line Input #3, strData
Print #2, strData
Loop Until EOF(2)

Close #2
Close #3

Open strPath1 For Binary Access Read As #1 ' Transactions
Open strPath For Append Access Write As #4 ' Header

'Merge C:\Trans.Txt with C:\Header.Txt
'This part fails with the Input past end of file error

Do Until EOF(1)
Line Input #1, strData '<< Error here
Print #4, strData
Loop 'While EOF(1) 'Until EOF(1)

Close #1
Close #4
End Sub

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++

Do Until EOF(2)
Line Input #2, strData
Write #1, strData
Loop

Close #1
Close #2

You just need to test for EOF first, I think. Of course, you have to
make sure then that you get the last record in textfile #1 into #2.

Nov 12 '05 #12

P: n/a
rkc

"Michael" <Mi******@HotMail.Com> wrote in message
news:43**************************@posting.google.c om...
I tried using the Do Until EOF but I get the same results.


Do While Not EOF(2)
Nov 12 '05 #13

P: n/a
rkc

----- Original Message -----
From: "Michael" <Mi******@HotMail.Com>
Newsgroups: comp.databases.ms-access
Sent: Tuesday, October 14, 2003 12:14 PM
Subject: Re: Appending Text file with a header record
<snip>
Open strPath1 For Append Access Write As #2 ' Transactions
Open strPath2 For Binary Access Read As #3 ' Trailer

'Merge c:\Trans.Txt with C:\Trans.Txt This part works

<code change>
Input$ ( lof(3), strData)
Print #2, strData
</code change>
Close #2
Close #3

Open strPath1 For Binary Access Read As #1 ' Transactions
Open strPath For Append Access Write As #4 ' Header

'Merge C:\Trans.Txt with C:\Header.Txt
'This part fails with the Input past end of file error

<code change>
Input$ (lof( 1) , strData)
Print #4, strData
</code change>
Close #1
Close #4
End Sub


Nov 12 '05 #14

P: n/a
When i try this ..

Input$ (lof( 1) , strData) << I get an Error here, "Compile Error Expected #"
Print #4, strData

Is this exactly how I should type this?

"rkc" <rk*@yabba.dabba.do.rochester.rr.com> wrote in message news:<rd*******************@twister.nyroc.rr.com>. ..
----- Original Message -----
From: "Michael" <Mi******@HotMail.Com>
Newsgroups: comp.databases.ms-access
Sent: Tuesday, October 14, 2003 12:14 PM
Subject: Re: Appending Text file with a header record
<snip>
Open strPath1 For Append Access Write As #2 ' Transactions
Open strPath2 For Binary Access Read As #3 ' Trailer

'Merge c:\Trans.Txt with C:\Trans.Txt This part works

<code change>
Input$ ( lof(3), strData)
Print #2, strData
</code change>
Close #2
Close #3

Open strPath1 For Binary Access Read As #1 ' Transactions
Open strPath For Append Access Write As #4 ' Header

'Merge C:\Trans.Txt with C:\Header.Txt
'This part fails with the Input past end of file error

<code change>
Input$ (lof( 1) , strData)
Print #4, strData
</code change>
Close #1
Close #4
End Sub

Nov 12 '05 #15

P: n/a
rkc

----- Original Message -----
From: "Michael" <Mi******@HotMail.Com>
Newsgroups: comp.databases.ms-access
Sent: Tuesday, October 21, 2003 6:48 PM
Subject: Re: Appending Text file with a header record

When i try this ..

Input$ (lof( 1) , strData) << I get an Error here, "Compile Error Expected #" Print #4, strData

Is this exactly how I should type this?

No. Don't know why I typed it like that.

strData = a variable of type string.

The following will cause the entire contents of the file opened as #1
to be loaded into strData.

strData = Input$(LOF(1), #1)

You should read up on the FreeFile function to assign a file handle.

Dim f1 as Long
f1 - FreeFile

Open "c:\Trans.Txt" For Binary As #f1


Nov 12 '05 #16

P: n/a
If anyone is interested here is how I solved my problem ..

Private Sub Command9_Click()

Dim strFirstQuery, strSecondQuery, strThirdQuery As String
Dim strPath, strPath1, strPath2 As String
Dim strData, strResult As String
Dim strtmp, strfulltmp As String

strPath = "c:\Header.txt" 'Header
Information file
strPath1 = "c:\Trans.Txt"
'Transactions file
strPath2 = "c:\Trailer.Txt" 'Trailer
file
strResult = "C:\Result.Txt" 'Result of
the three merged files

strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"
strThirdQuery = "QryTrailer"

'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1
'OutPut Transaction Trailer
DoCmd.TransferText acExportFixed, "EE2", strThirdQuery, strPath2

Open strPath For Input As #1 'Open Header
Open strPath1 For Input As #2 'Open Transactions File
Open strPath2 For Input As #3 'Open Trailer File
Open strResult For Output As #4 'Open Results File

Do While Not EOF(1)
Line Input #1, tmp
fulltmp = fulltmp & tmp & vbNewLine 'Read Header
Loop
Do While Not EOF(2)
Line Input #2, tmp
fulltmp = fulltmp & tmp & vbNewLine 'Read Transactions
Loop
Do While Not EOF(3)
Line Input #3, tmp
fulltmp = fulltmp & tmp & vbNewLine 'Read Trailer
Loop

Print #4, fulltmp 'Make Merged Results File

Close #4 'Close Files
Close #3
Close #2
Close #1
End Sub

Thanks for everyone's input!


Mi******@HotMail.Com (Michael) wrote in message news:<43**************************@posting.google. com>...
I have a data application in a2k that I need to create two fixed width
text files and then combine them to a single file The first file is
header information and the second is transaction data. I have tried
and tried but just cant seem to get this right, I am using Queries to
created my export files with specifications which works fine, I get
stumped with the appending the header to my transaction file. What I
have so far looks like this .. What I wind up in my file is,

1 2003100713250020441007
"c:\Trans.Txt"

What I need to know is how to declare the c:\trans.txt so it will
append data and not the string

Any help would be great!

Thanks

Michael

+++++++++++++++++++++++++++++++++++++++++++++++++

Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String

strPath = "c:\Header.txt" 'Header Information file
strPath1 = "c:\Trans.Txt" 'Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"

'Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
'OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1

Open strPath For Append As #1
Write #1, strPath1
Close #1

End sub

Nov 12 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.