vba 错误 3219 - 无效操作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12260032/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error 3219- Invalid Operation
提问by Kabi
I try to write a query in my Access Project but this runtime error occures in the line, where SQL query is. This is my code:
我尝试在我的 Access 项目中编写一个查询,但此运行时错误发生在 SQL 查询所在的行中。这是我的代码:
Private Sub Befehl80_Click()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT DISTINCT tb_KonzeptDaten.DFCC, tb_KonzeptDaten.OBD_Code AS Konzept_Obd,tb_KonzeptDaten.DFC INTO Test_Table FROM tb_KonzeptDaten", dbOpenDynaset)
Me.txtDs = rst.RecordCount
End Sub
Would you please tell me how can I solve this problem and why this error occures?
你能告诉我如何解决这个问题以及为什么会出现这个错误?
采纳答案by Fionnuala
The sql is an action query, it creates a table. You cannot open a recordset from an action query. If you want to run the action query, you can say:
sql 是一个动作查询,它创建一个表。您不能从操作查询中打开记录集。如果要运行操作查询,可以说:
Set db=CurrentDB
ssql="SELECT DISTINCT tb_KonzeptDaten.DFCC, " _
& "tb_KonzeptDaten.OBD_Code AS Konzept_Obd,tb_KonzeptDaten.DFC " _
& "INTO Test_Table FROM tb_KonzeptDaten"
db.Execute ssql, dbFailOnerror
RecordsUpdated=db.RecordsAffected