K
Karl Fuchs
Hello,
I use the following Code to control the Links of linked Tables and set
them to new Values:
Function fRefreshLinks() As Boolean
Dim dbs As DAO.Database, rst As DAO.Recordset, tdf As DAO.TableDef
Dim strOldConnect As String, strNewConnect As String,
strFullLocation As String
Dim strDatabase As String, strCompare As String, Zaehler As Long
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("SELECT Connect, Database, Name from
MSysObjects " & _
"WHERE Type = " &
IntAttachedTableType)
Zaehler = rst.RecordCount
If Zaehler <> 0 Then
rst.MoveFirst
strCompare = fstrAblPfad & "\" & Left(cstrAbl, Len(cstrAbl) -
1)
Do Until rst.EOF
If strPathfromFileName(rst("Database")) <> strCompare And
Left(rst("Database"), 2) <> "T:" Then
strFullLocation = rst("Database")
strDatabase = FileName(strFullLocation)
Set tdf = dbs.TableDefs(rst("Name"))
strOldConnect = tdf.Connect
strNewConnect = findConnect(strDatabase, tdf.Name,
strOldConnect)
tdf.Connect = strNewConnect
tdf.RefreshLink
dbs.TableDefs.Refresh
End If
rst.MoveNext
Loop
rst.Close
fRefreshLinks = True
End If
....
End Function
This Code almost works fine, however, sometimes it happens, that the
Code loops through the Recordset and doesn´t find the rst.EOF. That
means, that all Connections were refreshed, but at the last record the
code starts again with the fist record. Any idea about that?
Thank You
Karl
I use the following Code to control the Links of linked Tables and set
them to new Values:
Function fRefreshLinks() As Boolean
Dim dbs As DAO.Database, rst As DAO.Recordset, tdf As DAO.TableDef
Dim strOldConnect As String, strNewConnect As String,
strFullLocation As String
Dim strDatabase As String, strCompare As String, Zaehler As Long
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("SELECT Connect, Database, Name from
MSysObjects " & _
"WHERE Type = " &
IntAttachedTableType)
Zaehler = rst.RecordCount
If Zaehler <> 0 Then
rst.MoveFirst
strCompare = fstrAblPfad & "\" & Left(cstrAbl, Len(cstrAbl) -
1)
Do Until rst.EOF
If strPathfromFileName(rst("Database")) <> strCompare And
Left(rst("Database"), 2) <> "T:" Then
strFullLocation = rst("Database")
strDatabase = FileName(strFullLocation)
Set tdf = dbs.TableDefs(rst("Name"))
strOldConnect = tdf.Connect
strNewConnect = findConnect(strDatabase, tdf.Name,
strOldConnect)
tdf.Connect = strNewConnect
tdf.RefreshLink
dbs.TableDefs.Refresh
End If
rst.MoveNext
Loop
rst.Close
fRefreshLinks = True
End If
....
End Function
This Code almost works fine, however, sometimes it happens, that the
Code loops through the Recordset and doesn´t find the rst.EOF. That
means, that all Connections were refreshed, but at the last record the
code starts again with the fist record. Any idea about that?
Thank You
Karl