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

Transfer Database

Status
Not open for further replies.

ryan1

Programmer
May 15, 2002
106
US
I need a little help. I'm trying to import tables from another database. I know how to use the transferdatabase method, but a little uncertain on how to import all the tables from one database into mine at one time. I used the transfer database method and imported one table at a time , but i need to import all at one time. Any help would be great.
 
Hi sbutler,

Try something like this:


Dim dbs as Database
Dim I as Integer, MT as Integer
Dim strdbName as string

strdbName = "Set to the path of the DB to transfer from"
Set dbs = DBEngine(0).OpenDatabase(strdbName)

With dbs
For i = 0 To .TableDefs.Count - 1
MT = .TableDefs(i).Name
If left$(MT, 4) <> &quot;MSys&quot; Then
DoCmd.TransferDatabase acLink, &quot;Microsoft Access&quot;, strdbName, acTable, MT, MT
End If
Next i
End With

dbs.close

Let me know if this helps Regards,
gkprogrammer
 
By the way in the transferdatabase method I indicated aclink, which will just link these tables to the DB that is indicated, if you wish to just import them you can just leave this parameter blank as the default is acimport Regards,
gkprogrammer
 
Hey Thanks for the code. Its giving me a little trouble though. I'm getting a Type Mismatch Error and then it highlights the MT = .TableDef(I).Name when i put the cursor over the .TableDef(I) it shows my first table in the database i'm trying to import from? I see what your're doing though so i'm going to keep trying to figure out where the problem is. Thanks for the help i needed a point in the right direction.
 
MT was set as a Interger, and needed to be a string. Easy fix.
 
Oops....your right it should be a string, sorry for the mistake. Regards,
gkprogrammer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top