用于计算订单总额的DSum / Sum [英] DSum / Sum for calculating Order Total
问题描述
我正在尝试为餐馆创建食品订购系统。
我尝试过使用DSum和Sum函数来计算订单的总成本。总成本是tblOrder表单上的文本框(以及tblOrder中的字段),并且膳食列表及其成本在tblOrderDetail子表单中(此表单中的列来自两个表 - tblOrderDetails和tblItems)。
我一直把DSum / Sum放在控制权属性中。使用表达式构建器我尝试过:
DSum([tblOrderDetail Subform] .Form![Cost],[tblOrderDetail Subform] .Form)
结果:#error
= DSum([Cost],[tblOrder])结果:#name?
= DSum(" Cost"," tblOrder")结果:#error
= DSum(" [[Cost]",[tblOrder]")结果:#error
有时候我会得到 #name?错误,我可以通过使用更冗长的描述(不确定'是正确的单词)来解决,尽管所有的互联网示例只使用引号中的一个单词,或者我得到 #error 我根本无法解决。
我没有指定标准,因为我希望它计算该订单中所有项目的成本
表和表单都被称为tblOrder因为我没有更改Access在窗口中选择的名称wizzard
我正在使用Access 2000
I am trying to create a food order system for a restaurant.
I have tried using both the DSum and Sum functions to calculate the total cost of an order. The total cost is a textbox on the form tblOrder (and a field in tblOrder) and the list of meals along with their costs are in the tblOrderDetail Subform (the columns in this form come fromt two tables - tblOrderDetails and tblItems).
I have been putting the DSum / Sum in the control soure property. With the expression builder I have tried:
DSum ( [tblOrderDetail Subform].Form![Cost] , [tblOrderDetail Subform].Form )
result: #error
=DSum([Cost],[tblOrder]) result: #name?
=DSum("Cost","tblOrder") result: #error
=DSum("[Cost]","[tblOrder]") result: #error
Sometimes I get #name? error, which i can solve by using a more lengthy description (not sure that''s the right word) though all the internet examples only use one word in quotation marks, or i get #error which i can''t solve at all.
I haven''t specified a criteria as I wanted it to calculate the cost for all the items in that order
Both the table and the form are called tblOrder becasue I didnt change the name Access chose in the form wizzard
I am using Access 2000
推荐答案
什么是元数据对于桌子?即表的字段和它所拥有的数据类型。
What''s the meta data for the tables? i.e. The fields of the table and type of data it holds.
看看这个链接(规范化和表格结构)。它解释了为什么存储计算值不是一个好主意。
你确定tblItem表没有某种形式的名称字段吗?很难想象这可能是无关紧要的。
忽略[Total Cost]字段的更新,你需要一个名为qryOrder的QueryDef(保存的查询),其SQL是:
Check out this link (Normalisation and Table structures). It explains why storing the calculated value is not a good idea.
Are you sure the tblItem table doesn''t have a name field of some form? Hard to think this could be irrelevant.
Ignoring the updating of the [Total Cost] field, you will need a QueryDef (saved query) called something like qryOrder, whose SQL is :
这篇关于用于计算订单总额的DSum / Sum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!