I found this code by Peter Vulovic for reconnecting to linked tables.
I am getting the following error when tring to run:
Complie error:
User-defined type not defined
It then points to the second line of code
Dim db As Database
Any ideas??
Function Reconnect()
Dim db As Database
Dim source As String
Dim path As String
Dim dbsource As String
Dim i As Integer
Dim j As Integer
Set db = DBEngine.Workspaces(0).Databases(0)
For i = Len(db.Name) To 1 Step -1
If Mid(db.Name, i, 1) = Chr(92) Then
path = Mid(db.Name, i, 1)
'MsgBox(path)
Exit For
End If
Next
For i = 0 To db.tabledefs.Count - 1
If db.tabledefs(i).connect <> " " Then
source = Mid(db.tabledefs(i).connect, 11)
'Debug.Print source
For j = Len(source) To 1 Step -1
If Mid(source, j, 1) = Chr(92) Then
dbsource = Mid(source, j + 1, Len(source))
source = Mid(source, 1, j)
If source <> path Then
db.tabledefs(i).connetc = ";Database" + path + dbsource
db.tabledefs(i).RefreshLink
'Debug.Print "atabase=" + path+ dbsource
End If
Exit For
End If
Next
End If
Next
End Function
I am getting the following error when tring to run:
Complie error:
User-defined type not defined
It then points to the second line of code
Dim db As Database
Any ideas??
Function Reconnect()
Dim db As Database
Dim source As String
Dim path As String
Dim dbsource As String
Dim i As Integer
Dim j As Integer
Set db = DBEngine.Workspaces(0).Databases(0)
For i = Len(db.Name) To 1 Step -1
If Mid(db.Name, i, 1) = Chr(92) Then
path = Mid(db.Name, i, 1)
'MsgBox(path)
Exit For
End If
Next
For i = 0 To db.tabledefs.Count - 1
If db.tabledefs(i).connect <> " " Then
source = Mid(db.tabledefs(i).connect, 11)
'Debug.Print source
For j = Len(source) To 1 Step -1
If Mid(source, j, 1) = Chr(92) Then
dbsource = Mid(source, j + 1, Len(source))
source = Mid(source, 1, j)
If source <> path Then
db.tabledefs(i).connetc = ";Database" + path + dbsource
db.tabledefs(i).RefreshLink
'Debug.Print "atabase=" + path+ dbsource
End If
Exit For
End If
Next
End If
Next
End Function