Professional Documents
Culture Documents
Link To Access
Link To Access
Link To Access
"C:\mydatabase\DB.accdb"
"a"
Sub relinktables()
On Error GoTo relinktables_Err
'Routine to relink the tables automatically. Change the constant
LnkDataBase to the desired one and run the sub
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim strTable As String
Set dbs = CurrentDb()
For Each tdf In dbs.TableDefs
If Len(tdf.Connect) > 1 Then 'Only relink linked tables
If tdf.Connect <> ";DATABASE=" & txtDBPath Then 'only relink
tables if the are not linked right
strTable = tdf.Name
dbs.TableDefs(strTable).Connect =
txtDBPassword &
dbs.TableDefs(strTable).RefreshLink
End If
End If
Next tdf
MsgBox Error$
Resume relinktables_Exit
End Sub
------------