copy table

mdmilner

Well-known Member
Joined
Apr 30, 2003
Messages
1,362
Other than something like a Maketable, is there a VBA one-line technique to simply copy a table? Or any object for that matter.

Hmmm, DoCmd.CopyObject

Looks like maybe I posted too quickly.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi mdmilner,

Try:
DoCmd.CopyObject , "myTable2", acTable, "myTable"

myTable2 is what you will name the newly copied object
acTable is a constant meaning your copying a table, you can specify other object types in this parameter
myTable is the name of object to copy

If you start typing the method in the VB editor, Access will tell you where you are in the arguments, and provide choices when applicable.

Hope this helps,
 
Upvote 0
Yep, I started looking and didn't get anywhere - figured I could get a quick answer, and found what I was looking for in the next couple minutes.

Was using this for a quick table copy.
Rather than build a custom import wizard, I decided to piggy back off:

Runcommand acCmdImport (runs the default import wizard)

But I couldn't guarantee that the table name the user wants would be what they use at the end of the wizard. So, I wanted to check and then copy to new/delete old.

Still feels a little cumbersome, but, it'll work. (works already :biggrin: )

Mike
 
Upvote 0
I hate Access wizards. They sometimes use some really odd methods af getting where you want to go. Like the combobox wizard that takes you to the record you selected. What is that?

Glad you figured it out.
 
Upvote 0
Guess you can call this a shortcut. I've already got code samples scattered in 3 or 4 other databases I've built that do most of what I'll need for my own custom import "wizard" - I just need to assemble it into a slick/uniform GUI.

Mike
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,242
Members
451,756
Latest member
tommyw

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