Modify linked SQL table name in Access 2013

旧时模样 提交于 2019-12-13 07:28:54

问题


I have a SQL table linked in Access. I'd like to know how to change the linked table object to reference a different table with the same design but another name. For example, I link Table1 and create forms with it, and now need to change it to Table2.

There doesn't seem to be an easy way to do this.

  • The table Description in Design View contains all the linked database and table information but it's not editable.
  • Using the Linked Table Manager, I can change the database the table comes from, but the tables in both databases need to have the same name.
  • I can create a query with Select * From Table1 and change it to Select * From Table2 to switch tables, but I don't want to use a workaround if I don't have to.

回答1:


Remove the linked table, and use DoCmd.TransferDatabase to recreate the link with different names:

DoCmd.TransferDatabase acLink, "ODBC", your_ODBC_String, acTable, _
    "schema.source_table", "target_table"

You can look up your_ODBC_String from existing linked tables.

Add the StoreLogin:=True parameter if needed.



来源:https://stackoverflow.com/questions/36895630/modify-linked-sql-table-name-in-access-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!