预期:结束声明 [英] Expected: End of Statement

查看:88
本文介绍了预期:结束声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我收到了预期:结束声明来自我的代码的消息:


strSQL = strSQL& DLookUp(" [ID]"," qryListCopiesToDelete"," [ID]"> 1)))"

" [ID]" 突出显示为错误!如果我删除引号" qryListCopiesToDelete "成为问题等。当我从上面的脚本中删除所有引号时,警告会消失,但脚本无法正常工作!如何让DLookup读取查询?


所有查询都是在查询设计中构建的,并且作为普通查询工作,但是当我将代码放入vb时 - 没有!


请帮助,我在网上花了很多年,但无济于事。

Hi All
I am getting the "Expected: End of Statement" message from my code:

strSQL = strSQL & "DLookUp("[ID]", "qryListCopiesToDelete", "[ID]" >1)))"

"[ID]" gets highlighted as an error! If I remove the quotation marks "qryListCopiesToDelete" becomes the problem etc. When I remove all quotes from the above script the warnings go but the script fails to work! How do I get the DLookup to read the query?

All queries were built in Query Design and work as plain queries, but when I place the code into vb - NOTHING!

Help please, I have spent ages on the web but to no avail.

推荐答案

嗨。您的语句有两个问题:第一个是在字符串中包含双引号需要重复双引号字符(它毕竟是VBA中的分隔符,而VBA解释器看到字符串的结尾发生在之前您对DLookup中ID的引用。第二个错误,我在之前关于这个主题的类似帖子中也看到过,你的比较语句不正确 - > 1部分在比较之外。


排除这些错误,你的DLookup的StrSQL设置变为:

Hi. Two problems with your statement: the first being that to include double quotes within a string you need to repeat the double quote character (it is after all a delimiter in VBA, and the VBA interpreter is seeing the end of your string as occurring just before your reference to the ID in your DLookup). The second error, which I also saw in a similar post you made earlier on this topic, is that your comparison statement is incorrect - the > 1 part is outside of the comparison.

Sorting these errors out, your StrSQL setup for the DLookup becomes:

展开 | 选择 | Wrap | 行号


在任何情况下,SQL中的引号应该是单引号而不是双引号(从技术上讲 - 请参阅引号('')和双引号(") - 何时何地使用它们)。这样可以完全避免这个问题(虽然没有修复你的逻辑 - 请参阅斯图尔特的帖子)。
In any case, quotes within SQL should be single-quotes rather than double-quotes (technically speaking - see Quotes ('') and Double-Quotes (") - Where and When to use them). This would avoid the problem altogether (although not fix your logic - See Stewart''s post).


感谢Stewart(和NeoPa),错误消息已经消失!但是,正如你预测的那样,剧本不希望我想要它。


如果你能提供帮助的话!


我有一个查询从表中选择所有重复项,即qryListFirsts,(工作正常)。

然后我创建(在查询设计中)另一个查询qryListFirsts的查询。和原始表格以显示所有重复记录 - qryListCopiesToDelete (工作良好)。

我的最终查询qryDeleteDuplicates其SQL是:
Thanks Stewart (and NeoPa), the error message has gone away!! BUT as you predicted the script does not do want I want it to.

If you could help please!

I have a query which selects all duplicates from a table namely "qryListFirsts", (works fine).
I then created (in Query Design) another query which looks at the "qryListFirsts" and original Table to show all duplicate records - "qryListCopiesToDelete" (works fine).
My final query "qryDeleteDuplicates" whose SQL is:
展开 | 选择 < span class =codeDivider> | Wrap | 行号


这篇关于预期:结束声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆