从过滤的子表单中汇总记录 [英] Sum records from a filtered subform

查看:55
本文介绍了从过滤的子表单中汇总记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我对这个论坛不熟悉所以请耐心等待!我一直在2016年访问开发一年。我有一个未绑定的表单,包含子表单,列表框和3个文本框。子表单包含一个querydef,该querydef基于收据表和购买项目表(包含成本字段)之间的内部联接。多选列表框包含购买项目类别。 2个文本框是用于过滤日期和时间范围的选项。


我使用按钮根据列表框和2个文本框中的条件构建sql。一旦子窗体被过滤,我希望有一个按钮,将Cost字段汇总到窗体上的第3个文本框中,同时保留记录显示。


问题是我无法弄清楚如何做到这一点。这可能是一种简单的方法,当我看到它时,我的头靠在墙上。感谢任何帮助。

hi all
im new to this forum so be patient! ive been developing in access 2016 for a year. i have an unbound form with a subform, a listbox and 3 textboxes. the subform contains a querydef based on an inner join between a receipts table and items purchased table(which contains a "Cost" field). the multiselect listbox contains purchase item categories. 2 textboxes are options for filtering on dates and time frames.

i use a button to build the sql based on criteria from the listbox and 2 textboxes. once the subform is filtered i would like to have a button which sums the Cost field into the 3rd textbox on the form while preserving the records display.

problem is i cant figure out how to do it. theres probably a simple way to do it and ill bang my head against the wall when i see it. any help is appreciated.

推荐答案

在子表单的标题部分,添加一个包含以下记录源的文本框: = Sum ([成本])

这将对显示的记录的字段求和。
In the header section of your sub form, add a text box that had the following Record Source: =Sum([Cost])
This will sum that field for the records displayed.


thanx用于回复twinnyfo。我知道这很有效。有这么多的意见和只有一个回复我开始认为这是一个非常愚蠢的问题!无论如何,我应该提到子窗体控件中没有表格。 sourceobject是qrydef。我想在数据表视图中保持显示。我尝试使用默认为数据表视图的表单,但在使用您的代码时收到错误消息。生病再试一次表格。也许使用table和qrydef作为sourceobjects并不是一个好主意。
thanx for the reply twinnyfo. i know that works well. with so many views and only one reply i was beginning to think it was a pretty dumb question! anyway, i should have mentioned that the subform control does not have a form in it. the sourceobject is the qrydef. i want to keep the display in datasheet view. i tried using a form which defaulted to datasheet view but got an error msg when using your code. ill try it again with a form. maybe using tables and qrydefs as sourceobjects isnt such a good idea.


hi twinnyfo

这次您的建议有效。我的男朋友是一个ibm程序员,几乎不能容忍msaccess指出字段/控件名称冲突。我是一名小学老师,试图独自完成一些事情。我认为作为一名软件开发人员需要更多的承诺而不仅仅是一个周末战士< lol>。再次感谢。
hi twinnyfo
your suggestion worked this time. my boyfriend is an ibm programmer barely tolerates msaccess pointed out a field/control name conflict. im an elementary teacher trying to do a few things on my own. i think being a software developer requires more commitment than just being a weekend warrior <lol>. thanx again.


这篇关于从过滤的子表单中汇总记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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