Linked tables

J

Joop

Hi All,

Is there a way to manage linked tables from VBA?

What I want: change the link of all linked tables from one location to
another database with identical structure.

regards Joop
 
D

Dennis

Substitute your table names and paths in the following code sample

Sub Change_Link()
Dim dbConnect As Database
Dim tblConnect As TableDef
Dim strCon As String

Set dbConnect = CurrentDb
Set tblConnect = dbConnect.TableDefs("Test Table")
strCon = tblConnect.Connect
strCon = ";DATABASE=C:\Access\Link2.mdb"
tblConnect.Connect = strCon
tblConnect.RefreshLink
Set tblConnect = Nothing
Set dbConnect = Nothing
End Sub
 
Top