appending tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
Back
Top