I am trying to refresh the links on some tables with the following code using ADO.
Public Function RefreshLinks(vChangedSourceFile As String) As Boolean
Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
Set catDB = New ADOX.Catalog
‘ Open a Catalog object on the database in which to refresh links.
catDB.ActiveConnection = CurrentProject.Connection
catDB.Tables.Refresh
For Each tblLink In catDB.Tables
‘ Check to make sure table is a linked table.
If tblLink.Type = “LINK” And Left(tblLink.Name, 2) = “dt” Then
tblLink.Properties(“Jet OLEDB:Link Datasource”) = vChangedSourceFile
tblLink.Properties(“Jet OLEDB:Create Link”) = True
If Err Then
RefreshLinks = False
End If
End If
Next tblLink
Set catDB = Nothing
RefreshLinks = True
End Function
Running the function generates the following error message:
Run-time error ‘-2147217887 (80040e21)’
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
When I check the table properties, only the first ‘dt’ table was modifed?
Any clues/guesses as to why the code does not loop through all of the tables?
Thanks,