问题描述
使用Access 2010,我将几个Excel表格导入到Access中,并构建了允许用户更新表格和向表格中添加信息的表格.这些表单通过在VBA中动态生成SQL alter和update语句,然后运行DoCmd.RunSQL
来工作.但是,我希望对表的更改能够反映在原始Excel表中,因此我删除了Access中的表,而是将Excel表链接到Access.
Using Access 2010, I imported several Excel tables into Access, and built forms that allowed the user to update and add information to the tables. The forms work by dynamically generating SQL alter and update statements in VBA and then running DoCmd.RunSQL
. However, I wanted the changes to the tables to be reflected in the original Excel tables so I deleted the tables in Access, and instead linked the Excel tables to Access.
我所有的选择查询都继续起作用,因此我能够以基本上相同的方式访问数据,但是我无法使用DoCmd.RunSQL
在VBA中的表上执行SQL语句,这意味着我无法像以前一样执行SQL更新和alter语句.
All of my select queries continue to work so I am able to access the data in essentially the same way, but I am not able to execute SQL statements on the tables in VBA using DoCmd.RunSQL
, which means I can't perform the SQL update and alter statements like I did before.
我的问题是:我可以在链接的Excel表上执行包括alter和update语句的SQL吗,如果可以,怎么办?
My question is: can I execute SQL including alter and update statements on my linked Excel tables, and if so, how?
推荐答案
否,从Access的角度看,链接的工作表是只读的.这不仅是对Access SQL的限制.如果直接在数据表视图中打开这些链接之一,则无法更改存储的值,删除行或添加新行.
No, the linked worksheets are read-only from Access' perspective. That is not just a limitation for Access SQL. If you open one of those links directly in Datasheet View, you can not alter stored values, delete rows, or add new rows.
Microsoft 解释 ...
Microsoft explains ...
该编辑功能已在Access 2002和2003中删除,并且没有重新添加到后续的Access版本中.
That edit capability was removed with Access 2002 and 2003, and not added back to subsequent Access versions.
有关更多详细信息,请参见链接页面,包括其建议的解决方法.
See the linked page for further details, including their suggested workaround.
这篇关于在Access中的链接Excel表上执行SQL更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!