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

Linking Tables 1

Status
Not open for further replies.

shiggyshag

Programmer
Dec 14, 2001
227
GB
HI

I would like to be able to link tables via code
(not refresh but create)

I.e I have a database with no tables I then using code create linked table in it from another database all in code.

Hope that makes sense

Cheers
 
Hi

You can try this,

Sub LinkTableFromExtDB()

Dim myDb As Database
Dim myTdf As TableDef, myTableName As String

Set myDb = CurrentDb()
myTableName = "mainTable"

Set myTdf = myDb.CreateTableDef("mainTable", 0, "mainTable" _
, ";database=C:\LSTan\L S TAN Projects\VBA Projects\Access\mainDB.mdb")

myTdf.SourceTableName = "mainTable"
myDb.TableDefs.Append myTdf

End Sub


For more informations on the CreateTableDef method, look under the Access VBA help.

rgrds
LSTAN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top