DSum 返回行数而不是总值

发布于 2024-11-10 07:53:35 字数 235 浏览 2 评论 0原文

我将以下代码附加到表单中的文本框:

=DSum("[subform].Form![POINTS]","ATTENDANCE","[subform].Form![EMPLOYEE NO] = [EMPLOYEE NO]")

理想情况下,这将产生我们当前正在搜索的员工所获得的总积分。但是,我得到的是表中行的总和。

有人知道如何获得值的总和而不是行数吗?

谢谢

I have the following code attached to a text box in a form:

=DSum("[subform].Form![POINTS]","ATTENDANCE","[subform].Form![EMPLOYEE NO] = [EMPLOYEE NO]")

Ideally this would yield the total amount of points accrued by the employee we are currently searching for. However, what I am getting is the total sum of rows in my table.

Does anybody have any idea of how I could get the total sum of the values instead of the number of rows?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

幸福丶如此 2024-11-17 07:53:35

如果您想从子表单中获取总计,并且子表单与主表单同步,则按以下方式进行会更有效:

  1. 在子表单的页脚
  2. 引用主表单中的该控件: txtMainResult =subform!form!txtTotalPoints
  3. 隐藏 txtTotalPoints(或页脚本身)

这通常会快得多。

If you want to get the total from a subform, and your subform in in sync with the main one, it will be much more efficient to procede this way:

  1. create txtTotalPoints textbox = sum(Points) in the footer of your subform
  2. refer to that control from your main form: txtMainResult =subform!form!txtTotalPoints
  3. Hide txtTotalPoints (or the footer itself)

That will generally be much faster.

濫情▎り 2024-11-17 07:53:35

据我所知,DSum、DLookup、DCount 等域函数用于从表中查找并返回值。第一个参数是字段,第二个参数是表,第三个参数是确保获得正确记录集的条件或 WHERE 语句。您的第一个参数指的是表单的字段。我认为这是不正确的。 WHERE 语句中的第一项也是表单字段。我这这也是不正确的。你需要尝试这样的事情:

=DSum("POINTS","ATTENDANCE","[EMPLOYEE NO] = " & [subform].Form![EMPLOYEE NO])

As far as I know, the Domain functions such as DSum, DLookup, DCount etc. are used to lookup and return values from a table. The first argument is the field, the second the table, and the third is the criteria or WHERE statement that makes sure you get the correct set of records. Your first argument refers to a form's field. I think this is incorrect. Your first item in your WHERE statement is also a form field. I this this is also incorrect. You need to try something like this instead:

=DSum("POINTS","ATTENDANCE","[EMPLOYEE NO] = " & [subform].Form![EMPLOYEE NO])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文