here is some code you can experiment with. This codes tests if a table
in the TableDefs collections is linked by testing the connect string.
If the connectstring is not "" then it is a linked table.
Sub tblLinks()
Dim DB As DAO.Database, tdf As DAO.TableDef
Set DB = CurrentDb
For Each tdf In DB.TableDefs
If tdf.Connect <> "" Then Debug.Print tdf.Name & " is a linked
table"
'--or
'If (tdf.Attributes And dbAttachedTable) = dbAttachedTable Then
Debug.Print tdf.Name; " is a linked table"
Next
End Sub
And to re-link a table you can do this :
Sub ReLink()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strPath As String
strPath = "<SomePathToBackEndDatabase>"
Set db = CurrentDb()
For Each tdf In db.TableDefs
If (tdf.Attributes AND dbAttachedTable) = _
dbAttachedTable Then
tdf.Connect = ";DATABASE=" & strPath
tdf.RefreshLink
End If
Next
Rich
*** Sent via Developersdex
http://www.developersdex.com ***