Export Text

  • Thread starter Thread starter Charles
  • Start date Start date
C

Charles

I need to export the contents of three queries into one text file. An
"OrderID" field relates all three queries and a "TableID" field
differentiates them.



Here is an example of the result I'm searching for:

The resulting ASCII text file must have as its first line the FIRST record
from "Query A". The second line should be the RELATED FIRST record in Query
B. The third line should be the RELATED FIRST record in Query C. The
fourth line should be the SECOND record from Query A. The fifth line should
be the RELATED SECOND record from Query B. The sixth line should be the
RELATED SECOND record from Query C......and so on through the entire
recordset.



Is this even possible in Access?



Thank you.
 
Hi Charles,

This can be done as follows:

1) Ensure that all three queries return the same number of fields. If
necessary add dummy calculated fields, e.g.
ExtraField: ""
to the query or queries that have fewest fields.

If you have a tidy mind you will also want to ensure that every field in
each query has the same data type as the corresponding fields (counting
from the first) in the other two queries. If you're exporting to a text
file you may well already be converting numeric or date fields to text
as you format them with the Format() function.

2) Create a Union query that gets records from all three queries and
returns them in the order you want. It will be something like

SELECT * FROM QueryA
UNION
SELECT * FROM QueryB
UNION
SELECT * FROM QueryC
ORDER BY OrderID, TableID;
 
Back
Top