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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy table between two database files.

Status
Not open for further replies.

softlover

Programmer
Apr 4, 2002
88
0
0
CN
Now I have three database files:
file1.mdb,file2.mdb,file3.mdb
I need file1.mdb opened and copy tables from file2.mdb to file3.mdb.
I know the command "DoCmd.CopyObject" can copy current table objects (in opened database file1.mdb) to another database. But I don't know the way to copy objects between other two database.
Another way to get the same result: copy table from file2.mdb to current database(file1.mdb), then copy this table to file3.mdb. But I don't like this method.
Anyone help me with this problem, Thanks in advance
 
How are ya softlover . . .

Have a look at the [blue]DoCmd.TransferDatabase[/blue] method!

Calvin.gif
See Ya! . . . . . .
 
Thanks to TheAceMan1, But the "Docmd.TransferDatabase" command make the same result as "Docmd.CopyObject".
 
softlover . . .

I should've known, maybe its too early yet.

Currently sifting thru my library . . .

Calvin.gif
See Ya! . . . . . .
 
softlover

you need the other database instance opened (file2.mdb with acExport, file3.mdb with acImport argument) to do the DoCmd.TransferDatabase method... for other mdbs!
Code:
Dim objAccess As Object
Set objAccess = CreateObject("Access.Application")
objAccess.OpenCurrentDatabase "c:\file2.mdb"
objAccess.Visible = True
objAccess.DoCmd.TransferDatabase acExport, , , acTable, "YourTableName", "C:\file3.mdb"
objAccess.CloseCurrentDatabase
Set objAccess = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top