Hi John,
Thanks for your help.
Problem is not solved yet. Big point is the complete diff. export specs per
file. These are limited.
File contains;
Headers, no problem
Line1 file 1
Line1 file 2
Line2 file 1
Line2 file 2
etc.
Footer, no problem
File 1 specs:
Field 1, start 1 width 3
Field 2, start 4, width 3
Field 3, start 7, width 40
Field 4, start 47, width 40
Upto field 82 endwidth 1223
File 2 specs:
Field 1, start 1 width 3
Field 2, start 4, width 8
Field 3, start 12, width 12
Field 4, start 24, width 20
Upto field 16 endwidth 229
When i merge the two query's first via a apendquery into one table and
export the table as far as I know I can only use one export spec.
Now we export both files and copy/past all lines together.
Our customer we send the file to is a big international company otherwise I
had ask them to change their input.
BR,
Dirk
> Hi Dirk,
>
[quoted text clipped - 27 lines]
>
> Please respond in the newgroup and not by email.
John Nurick - 07 Feb 2005 22:06 GMT
Hi Dirk,
There are several ways to go. Here are a couple:
1) export the two files as now, then run a script (outside Access) to
interleave them. Here's a Perl script that does the job; you can do the
same thing (if less compactly) in VBScript or other languages:
#Perl script to interleave text files line by line
use strict;
die "Usage:\n perl interleave.pl file1 file2 outfile\n"
unless $ARGV[2];
open IN1, $ARGV[0] or die "Sorry, couldn't open $ARGV[0]. ";
open IN2, $ARGV[1] or die "Sorry, couldn't open $ARGV[1]. ";
open OUT, ">$ARGV[2]" or die "Sorry, couldn't create $ARGV[2].";
my ($in1, $in2);
print OUT "$in1$in2" while (($in1 = <IN1>) && ($in2 = <IN2>));
#end of script
2) In Access VBA, open a recordset on each query and a single textfile,
then assemble and write a line from each recordset in turn. Pseudocode:
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Set rst1 = DBEngine(0)(0).OpenRecordset(blah blah)
Set rst2 = DBEngine(0)(0).OpenRecordset(blah blah)
Open "C:\folder\file.txt" For Output As #1
Do Until (rst1.Eof Or rst2.Eof)
With rst1
strLine = Format(.Fields(1), "blah") _
& Format(.Fields(2) "blah" _
....
#assemble a string containing the record you want to write
Print #1, strLine
End With
With rst2
...
End With
rst1.MoveNext
rst2.MoveNext
Loop
Close #1
rst1.Close
rst2.Close
>Hi John,
>
[quoted text clipped - 64 lines]
>>
>> Please respond in the newgroup and not by email.
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.