appending tables

A

Allen_N

I have created a routine for appending two tables (in an Access Project) to
create a third one, but I think it could be improved.

DoCmd.CopyObject , txtTableNew, acTable, txtTable1
strSQL = "INSERT INTO [" & txtTableNew & "] " _
& "SELECT * FROM [" & txtTable2 & "]"
CurrentProject.Connection.Execute strSQL, dbFailOnError

The DoCmd.CopyObject takes ages to execute for a large table, while the
INSERT INTO is quite fast. What is a better way to do this?

Thanks!

-- Allen
 
A

Andy Hull

Hi

Try...

strSQL = "SELECT * INTO [" & txtTableNew & "] " _
& "FROM [" & txtTable1 & "]"
CurrentProject.Connection.Execute strSQL, dbFailOnError
strSQL = "INSERT INTO [" & txtTableNew & "] " _
& "SELECT * FROM [" & txtTable2 & "]"
CurrentProject.Connection.Execute strSQL, dbFailOnError


hth

Andy Hull
 
A

Allen_N

Thanks Andy.

What a difference!

Andy Hull said:
Hi

Try...

strSQL = "SELECT * INTO [" & txtTableNew & "] " _
& "FROM [" & txtTable1 & "]"
CurrentProject.Connection.Execute strSQL, dbFailOnError
strSQL = "INSERT INTO [" & txtTableNew & "] " _
& "SELECT * FROM [" & txtTable2 & "]"
CurrentProject.Connection.Execute strSQL, dbFailOnError


hth

Andy Hull


Allen_N said:
I have created a routine for appending two tables (in an Access Project) to
create a third one, but I think it could be improved.

DoCmd.CopyObject , txtTableNew, acTable, txtTable1
strSQL = "INSERT INTO [" & txtTableNew & "] " _
& "SELECT * FROM [" & txtTable2 & "]"
CurrentProject.Connection.Execute strSQL, dbFailOnError

The DoCmd.CopyObject takes ages to execute for a large table, while the
INSERT INTO is quite fast. What is a better way to do this?

Thanks!

-- Allen
 

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