Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim strSourceTableName As String
Dim strCurrentPath As String
Dim strAttachPath As String
Dim strFrontendPath As String
Dim strBackendPath As String
Dim strConnect As String
On Error GoTo Err_GentilknytData
Set dbs = CurrentDb
strFrontendPath = dbs.Name
strCurrentPath = Mid(strFrontendPath, 1, InStrRev(strFrontendPath, "\") - 1)
For Each tdf In dbs.TableDefs
strSourceTableName = tdf.SourceTableName
If Len(strSourceTableName) > 0 Then
strBackendPath = Split(tdf.Connect, "=")(1)
strAttachPath = Mid(strBackendPath, 1, InStrRev(strBackendPath, "\") - 1)
If StrComp(strCurrentPath, strAttachPath, vbTextCompare) <> 0 Then
strConnect = ";DATABASE=" & strCurrentPath & "\AktivitetData.mdb"
tdf.Connect = strConnect
tdf.RefreshLink
End If
End If
Next
Set tdf = Nothing
Set dbs = Nothing
|