Public Function RefreshTableLinks()
Dim tbl As DAO.TableDef
Dim db As DAO.Database
Dim sPath As String
Dim sFileName As String
Dim sConnect As String
Dim iBeg As Integer
Dim iEnd As Integer
Set db = CurrentDb
sPath = CurrentProject.Path
'Sample connection string: _
sConnect = "Text;" & _
"DSN=RV_DAILY_TEST Link Specification;" & _
"FMT=Fixed;" & _
"HDR=NO;" & _
"IMEX=2;" & _
"CharacterSet=437;" & _
"DATABASE=" & sPath & ";" & _
"TABLE=RV_DAILY_TEST#txt"
For Each tbl In db.TableDefs
If tbl.Name = "RV_DAILY_TEST" Then
sConnect = tbl.Connect 'Store connection to string for faster processing
iBeg = InStr(sConnect, "DATABASE=") 'Get the location of the filepath
iEnd = InStr(iBeg, sConnect, ";") 'Get the location of where the path ends
tbl.Connect = Left$(sConnect, iBeg - 1) & _
"DATABASE=" & sPath & _
right$(sConnect, IIf(iEnd = 0, 0, Len(sConnect) - iEnd))
tbl.RefreshLink
End If
Next
End Function