I have a LinkTable which points to an existing table of SQL server in my Access database. I need to change the 'Description' property value for that table link.
I had tried many ways but failed to do that.
Can any any one help me in this regard ?
I have a LinkTable which points to an existing table of SQL server in my Access database. I need to change the 'Description' property value for that table link.
I had tried many ways but failed to do that.
Can any any one help me in this regard ?
Some notes.
Dim db As DAO.Database
Dim tdf As TableDef
Set db = CurrentDb
Set tdf = db.TableDefs("Table1")
On Error Resume Next
tdf.Properties("Description") = "Link"
If Err.Number = 3270 Then 'property not found
Set prp = tdf.CreateProperty("Description", dbText, "Link")
tdf.Properties.Append prp
End If
@Fionnuala's answer gets us 90% of the way there, but to change the description of a linked table, you need to connect to the db the linked table is stored in.
Dim tblName As String
Dim db As DAO.Database
Dim tdf As DAO.TableDef
tblName = "Table1"
Set db = CurrentDb
Set tdf = db.TableDefs(tblName)
If Left(tdf.Connect, 10) = ";DATABASE=" Then
'if this is a linked table, connect to linked db
Set db = OpenDatabase(Mid(tdf.Connect, 11))
Set tdf = db.TableDefs(tblName)
End If
On Error Resume Next
tdf.Properties("Description") = "Link"
If Err.Number = 3270 Then 'property not found
Dim prp As DAO.Property
Set prp = tdf.CreateProperty("Description", dbText, "Link")
tdf.Properties.Append prp
End If
Without connecting to the linked table's db, the description will be stored in the currentdb, but the table's actual description will not be effected.
© 2022 - 2024 — McMap. All rights reserved.