我有一些代码可以重新排列表单上的一些项目,但只有一个 SQL 查询。我的所有表在代码运行之前都没有锁定,但由于某种原因,我在运行时收到错误:
DoCmd.RunSQL ("Select * Into MasterTable From Year07 Where 'ClassName' = '7A'")
错误:
The database engine could not lock table because it is already in use by another person or process. (Error 3211) To complete this operation, a table currently in use by another user must be locked. Wait for the other user to finish working with the table, and then try the operation again.
我可以采取什么措施来阻止表被锁定?
最佳答案
MasterTable 是否包含在您表单的记录源中?如果是这样,当表单打开时,您无法替换它或修改其结构。
除了表锁问题之外,SELECT 语句中还存在逻辑错误。
Where 'ClassName' = '7A'
字符串ClassName永远不会等于字符串7A。因此,您的 SELECT 永远不会返回任何记录。如果 ClassName 是 Year07 表中的字段名称,请丢弃字段名称周围的引号。
Where ClassName = '7A'
关于ms-access - 调用 RunSQL 时表已锁定或正在使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4034881/