数据类型不匹配在某些情况下而不是其他情况
我正在MS Access中构建表单,并想添加一个简单的文本字段 dsum()
基于数据库中的查询功能。我不断得到的错误是
标准表达式中的数据类型不匹配。
但是,在解决问题时,我找不到不匹配的问题。该字段在选择语句中似乎还可以,但在某个语句中,根据以下语句中的字段无效:
- 原始文本框公式:
format(dsum(“ pvalue”,“ n_qryplbreakdown”,“ N_Qryplbreakdown”,“阶段”不喜欢“*丢失*”。 “),“£#,## 0 ;;£ - ”)
- 返回相同错误的查询:
SELECT SUM(N.PValue) AS SUMVAL
FROM N_qryPLBreakdown AS N
WHERE NOT N.Stage LIKE "*Lost*"
- 但是此查询不给出任何错误:
SELECT SUM(N.PValue) AS SUMVAL, N.Stage LIKE "*Lost*" AS MismatchField
FROM N_qryPLBreakdown AS N
GROUP BY N.Stage LIKE "*Lost*"
我也尝试了a <<代码>选择将查询n_qryplbreakdown
放入表格中,然后查看数据类型。令人反感的“舞台”字段是一个正常的短文本字段,大小为255,所有上述查询/功能都可以使用。但是,我正在运行的查询非常动态,我不想继续将结果放入表中。
请帮助我在这里确定问题吗?查询是什么,它会在某个语句中抛出错误,但在组中没有错误的错误?
I am building a form in MS Access, and want to add a text field with a simpleDSum()
function based on a query in my database. The error I keep on getting is
Data type mismatch in criteria expression.
However when troubleshooting the issue, I can't find what's mismatching. The field seems ok in a SELECT statement but invalid in a WHERE statement, per the below:
- Original text box formula:
Format(DSum("PValue","N_qryPLBreakdown","Stage Not Like ""*Lost*"""),"£#,##0;;£ -")
- A query that returns the same error:
SELECT SUM(N.PValue) AS SUMVAL
FROM N_qryPLBreakdown AS N
WHERE NOT N.Stage LIKE "*Lost*"
- But this query doesn't give any errors:
SELECT SUM(N.PValue) AS SUMVAL, N.Stage LIKE "*Lost*" AS MismatchField
FROM N_qryPLBreakdown AS N
GROUP BY N.Stage LIKE "*Lost*"
I also tried a SELECT INTO
to put the results of the query N_qryPLBreakdown
into a table, and looked at the datatype. The offending 'Stage' field was a normal short text field of size 255, and all of the above queries/functions worked on that. However the query I'm running from is very dynamic and I don't want to keep putting the results into a table.
Please help me identify the problem here? What is the query doing that it will throw an error in a WHERE statement but no error for the same thing in a GROUP BY?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是
在错误的位置:如果只有一个“丢失”选项,请尝试以下操作:
The
NOT
is in the wrong place:If only one 'Lost' option, try with: