- Local time
- Today, 04:31
- Joined
- Oct 29, 2018
- Messages
- 21,358
Hi. Try amending the code as such then:I get a debug on this line: If .Connect <> "" Then
"Object no longer set"
Code:
Option Compare Database
Option Explicit
Public Const CONN_STRING As String = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=GCDF_DB;Data Source=BADLANDS"
Public Sub RelinkTable(TableName As String)
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Set db = CurrentDb()
Set tdf = db.TableDefs(TableName)
With tdf
If .Connect <> "" Then
.Connect = CONN_STRING
.RefreshLink
End If
End With
Set tdf = Nothing
Set db = Nothing
End Sub