Appending tables

C

CAM

Hello,

I have 5 tables:
Table A
Table B
Table C
Table D
Table E

All I want to do is to append tables A-E to Table F.

What will be the quickest way to go about it. Any tips will be appreciated.
Thank you in advance.
 
A

Allen Browne

If the tables have identical field names, of the same data type, in the same
order, and there is no issue with duplicated ID values, you could do it by
with 4 append queries.

To do the job programmatically:
Dim db As DAO.Database
Dim strSql As String

Set db = dbEngine(0)(0)
strSql = "INSERT INTO E SELECT A.* FROM A;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT B.* FROM B;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT C.* FROM C;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT D.* FROM D;"
db.Execute strSql, dbFailOnError
 
A

arthurjr07

if you dont want to
program,
another way is to
create a Append Query
like this..

INSERT INTO F
SELECT * FROM
(
SELECT*FROM A
Union
SELECT*FROM B
Union
SELECT*FROM C
Union
SELECT*FROM D
Union
SELECT*FROM E
) AS ABCDE
 
C

CAM

Thanks Again I appreciate your advice

Allen Browne said:
If the tables have identical field names, of the same data type, in the
same order, and there is no issue with duplicated ID values, you could do
it by with 4 append queries.

To do the job programmatically:
Dim db As DAO.Database
Dim strSql As String

Set db = dbEngine(0)(0)
strSql = "INSERT INTO E SELECT A.* FROM A;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT B.* FROM B;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT C.* FROM C;"
db.Execute strSql, dbFailOnError

strSql = "INSERT INTO E SELECT D.* FROM D;"
db.Execute strSql, dbFailOnError
 

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