数据类型不匹配在某些情况下而不是其他情况

发布于 2025-01-24 08:22:41 字数 873 浏览 1 评论 0原文

我正在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 simple
DSum() 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不及他 2025-01-31 08:22:41

不是在错误的位置:

WHERE N.Stage NOT LIKE "*Lost*"

如果只有一个“丢失”选项,请尝试以下操作:

WHERE N.Stage <> 'Closed - Lost'

The NOT is in the wrong place:

WHERE N.Stage NOT LIKE "*Lost*"

If only one 'Lost' option, try with:

WHERE N.Stage <> 'Closed - Lost'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文