Access Macro - Copy and rename table

mk000

Board Regular
Joined
Dec 10, 2004
Messages
234
Hi,

I have two tables, one named Old, one named new. Each table has the same structure. Each week I need to delete the contents of the new table. I then need to cut all the old table values and paste them into the new table.

Anyone know how I can do this with vba?

mk
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You can do it with a macro (which you can convert to VBA code if you like).

To delete the data out of the one table, just use a RunSQL Macro command with this line of code:
Code:
DELETE [Table1].* FROM [Table1]
(substituting in your table name).

Then, create an Append Query to copy all your data from the one table to the other. Then just use the OpenQuery Macro command to run that Append Query.
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top