Export 5 Tables into one ASC file

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Can I export 5 different tables into one ASC file? If so, how?
 
G

Granny Spitz via AccessMonster.com

mattc66 said:
Can I export 5 different tables into one ASC file? If so, how?

Yes, if the table structures are the same you can append a union query into a
text file. But if all 5 tables have the same structure, *why*? It should be
one table with all those records. And if they don't, why would you put 5
dissimilar tables in the same sequential file?

First create a union query like this:

SELECT *
FROM tbl1
UNION ALL
SELECT *
FROM tbl2
UNION ALL
SELECT *
FROM tbl3
UNION ALL
SELECT *
FROM tbl4
UNION ALL
SELECT *
FROM tbl5;

If you don't want duplicate records, remove the the ALL from every UNION ALL.
Save this and name it qryUnion. Create a new query like this and run it:

SELECT * INTO [Text;HDR=YES;DATABASE=C:\IMDB\].Textfile.txt
FROM qryUnion;
 
M

mattc66 via AccessMonster.com

They are different tables. Its for EDI 850 ascii file upload.

Granny said:
Can I export 5 different tables into one ASC file? If so, how?

Yes, if the table structures are the same you can append a union query into a
text file. But if all 5 tables have the same structure, *why*? It should be
one table with all those records. And if they don't, why would you put 5
dissimilar tables in the same sequential file?

First create a union query like this:

SELECT *
FROM tbl1
UNION ALL
SELECT *
FROM tbl2
UNION ALL
SELECT *
FROM tbl3
UNION ALL
SELECT *
FROM tbl4
UNION ALL
SELECT *
FROM tbl5;

If you don't want duplicate records, remove the the ALL from every UNION ALL.
Save this and name it qryUnion. Create a new query like this and run it:

SELECT * INTO [Text;HDR=YES;DATABASE=C:\IMDB\].Textfile.txt
FROM qryUnion;
 
D

Douglas J. Steele

You'll either have to export them into 5 separate files, then, and somehow
add the 5 files together into 1, or you'll have to manually export the
values in the table to a text file using the Open, Print # and Close
statements in VBA.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


mattc66 via AccessMonster.com said:
They are different tables. Its for EDI 850 ascii file upload.

Granny said:
Can I export 5 different tables into one ASC file? If so, how?

Yes, if the table structures are the same you can append a union query
into a
text file. But if all 5 tables have the same structure, *why*? It should
be
one table with all those records. And if they don't, why would you put 5
dissimilar tables in the same sequential file?

First create a union query like this:

SELECT *
FROM tbl1
UNION ALL
SELECT *
FROM tbl2
UNION ALL
SELECT *
FROM tbl3
UNION ALL
SELECT *
FROM tbl4
UNION ALL
SELECT *
FROM tbl5;

If you don't want duplicate records, remove the the ALL from every UNION
ALL.
Save this and name it qryUnion. Create a new query like this and run it:

SELECT * INTO [Text;HDR=YES;DATABASE=C:\IMDB\].Textfile.txt
FROM qryUnion;
 
Top