Some trouble with RefreshLinks


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
 
Ad

Advertisements

G

Guest

Karl, have you done a trace in the code to see where this is happening? I
suspect the dbs.TableDefs.Refresh line may be the problem. I don't think it
really needs to be there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top