Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy access tables

Status
Not open for further replies.

gerrythistle

Technical User
Dec 2, 2002
8
CA
Hi:

Anybody able to suggest a method to copy an access table in it's entirety to another access database from with visual basic.
 
One way to do it would be to use the Access application itself to do the work. There is a DoCmd method, CopyObject, that will do exactly what you want. I tried the following code, and it worked (although it did, quite annoyingly, open the Northwind Database breifly on my computer before it shut it back down)

Private Sub Command3_Click()
Dim AccApp As Access.Application
Set AccApp = New Access.Application

AccApp.OpenCurrentDatabase "C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB", False
AccApp.DoCmd.CopyObject "C:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB", "Employees2", acTable, "Employees"
AccApp.Quit acQuitSaveNone

That successfully copied the Employees table from the Northwind Database to the Biblio database, and named the table Employees2, complete with data. Except for that annoying flashing of Access opening breifly, it works great.

If the flashing of Access isn't acceptable, post back and we can think about it some more.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top