运行此 Access VBA 查询时如何避免运行时错误 3075?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/428292/
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
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 10:09:52 来源:igfitidea点击:
How can I avoid runtime error 3075 when running this Access VBA query?
提问by tksy
Can someone tell what is wrong with this query?
有人能说出这个查询有什么问题吗?
sqltext = "SELECT utyp, count(*) AS anzahl
INTO UTYP_Anzahl FROM 01_umwelt
WHERE [01_umwelt].status = Me.Controls(""STATUS"").Value
GROUP BY utyp;"
I am getting run time error 3075.
我收到运行时错误 3075。
回答by Birger
The SQL you are using is not valid. You must escape the query string when adding a reference to a control. Also, you can get the control directly by it's name. Try the following:
您使用的 SQL 无效。添加对控件的引用时,您必须对查询字符串进行转义。此外,您可以直接通过名称获取控件。请尝试以下操作:
sqltext = "SELECT utyp, count(*) AS anzahl INTO UTYP_Anzahl " _
& "FROM 01_umwelt WHERE [01_umwelt].status = " _
& STATUS.Value _
& " GROUP BY utyp;"