PDA

View Full Version : Relinking Code issue



RPFeynman06
05-20-2022, 06:00 PM
I have a client using of all things DBF files. Now I run the code below and can refresh the links but when I try to change the td.connect by uncommenting it, I get the error the path is invalid. Any ideas?



Function relinkDBF()
Dim db As DAO.Database, rs As DAO.Recordset, tds As DAO.TableDefs, td As DAO.TableDef, ErrCount As Integer

Set db = CurrentDb
Set tds = db.TableDefs

On Error GoTo Err_Proc
For Each td In tds
'td.Connect = "dBASE III;HDR=NO;IMEX=2;ACCDB=YES;DATABASE= C:\Users\Sergi.Arthur\Desktop\TJS051622"
If Right(td.SourceTableName, 3) = "DBF" Then
Debug.Print Right(td.SourceTableName, 3), td.SourceTableName, td.NAME, td.Connect
td.RefreshLink
End If
Next
Exit_Proc:
Exit Function
Err_Proc:
Select Case Err.NUMBER
Case 3011
ErrCount = ErrCount + 1
Resume Next
Case Else
MsgBox Err.NUMBER & "-" & Err.Description
Resume Exit_Proc
End Select
End Function

arnelgp
05-21-2022, 06:58 AM
see this link, it need the .Connect property to be filled first before issueing .RefreshLink.
TableDef.RefreshLink method (DAO) | Microsoft Docs (https://docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/tabledef-refreshlink-method-dao)

RPFeynman06
05-23-2022, 05:50 AM
see this link, it need the .Connect property to be filled first before issueing .RefreshLink.
TableDef.RefreshLink method (DAO) | Microsoft Docs (https://docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/tabledef-refreshlink-method-dao)


You can see that this is the case from my code.

arnelgp
05-23-2022, 06:25 AM
You can see that this is the case from my code.
is it? you Comment out the Connect part.