Here's a solution:
Code:
Sub RelinkTables(ByVal SearchPath As String)
'
' Note: A reference to the Microsoft Office Object Library is needed.
' ---- For Access 2003: Menu "Tools" --> "References" --> "Microsoft Office 12.0 Object Library"
'
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim strDBName As String
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If tdf.Connect <> "" Then
Debug.Print tdf.Name, tdf.Connect
strDBName = Mid(tdf.Connect, InStrRev(tdf.Connect, "\") + 1)
Debug.Print strDBName
With Application.FileSearch
.NewSearch
.SearchSubFolders = True
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
.FileName = strDBName
.LookIn = SearchPath
.Execute
If .FoundFiles.Count = 0 Then
MsgBox "File: " & strDBName & "was not found.", vbInformation, "RelinkTables"
ElseIf .FoundFiles.Count = 1 Then
tdf.Connect = ";DATABASE=" & .FoundFiles(1)
tdf.RefreshLink
Else
MsgBox "Several files named: " & strDBName & " were found.", vbInformation, "RelinkTables"
End If
End With
End If
Next tdf
Set dbs = Nothing
End Sub
You can call the procedure like this:
Code:
RelinkTables "O:\master"
Warning: Make a copy of the original database before using this procedure, just in case something goes wrong.