在Access中更改链接表中的表名 [英] Change table name in linked table in Access
问题描述
我正在尝试在Access中更改表的名称.我已经去了链接管理器并完成了该过程.它将更改为我放置的服务器,但从不更改表名称(以黄色突出显示).
I'm trying to change the name of a table in Access. I've gone to the link manager and gone through that process. It will change to the Server I put it, but it never changes the Table name (Highlighted in yellow).
推荐答案
似乎您的目标是更改链接的TableDef
的SourceTableName
,但是我怀疑这是否可能.尝试执行此操作会触发错误#3268:
It seems your goal is to change the linked TableDef
's SourceTableName
, but I doubt that is possible. Attempting to do it triggers error #3268:
对象成为集合的一部分后就无法设置此属性.
Cannot set this property once the object is part of a collection.
因此,我认为您将必须使用旧链接的Connect
属性和新的SourceTableName
值以及Append
到TableDefs
集合的新链接创建TableDef
.
So I think you will have to create a new linked TableDef
with the Connect
property from the old link and your new SourceTableName
value and Append
that to the TableDefs
collection.
Const cstrOldName As String = "dbo_tblFoo2"
Dim db As DAO.Database
Dim tdfOld As DAO.TableDef
Dim tdfNew As DAO.TableDef
Set db = CurrentDb
Set tdfOld = db.TableDefs(cstrOldName)
tdfOld.Name = cstrOldName & "_old" ' rename the old link
Set tdfNew = db.CreateTableDef
With tdfNew
.Name = cstrOldName
.Connect = tdfOld.Connect
.SourceTableName = "dbo.Dual"
End With
db.TableDefs.Append tdfNew
这篇关于在Access中更改链接表中的表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!