I'm trying to set the TableDef.connect property when my DB opens but it is coming through as a read only property. I have tried various methods and did a search online. All of the example I have found seem to line up with what I have coded in this module. Can anyone see a reason why I can't set the connect property in the code below?
AtlasAF
Code:
Public Function RelinkTables(strPath As String) As Integer
Dim db As DAO.Database
Dim tdfs As DAO.TableDefs
Dim tdf As DAO.TableDef
Dim strStat As String
On Error GoTo Err:
strStat = Chr(17)
Set db = CurrentDb
Set tdfs = db.TableDefs
strPath = ";DATABASE=" & strPath
For Each tdf In tdfs
With tdf
.Connect = strPath
.RefreshLink
End With
Next tdf
MsgBox "Connection to: " & strPath & " Successful", vbOKOnly, "Connection Successful"
Set tdf = Nothing
Set db = Nothing
GoTo ExitFunction
Err:
MsgBox "Error Number: " & Err.Number & " Description: " & Err.Description
Set tdf = Nothing
Set rs = Nothing
Set db = Nothing
ExitFunction:
End Function
AtlasAF