访问Grand Total不正确

时间:2014-12-01 17:18:43

标签: access-vba formulas totals

我有一个我一直在使用的访问报告,它使用详细信息中的公式来添加行。然后我想要Total Total那个Total列。行上的总计工作正常,但是Grand Total并未正确添加所有内容。

每行的公式总计

=IIf([Pkg] Like "*Large Drum*",[SQtyProd]*[DrmChrg],[SQtyPD]*[PltChrg])+[XPallet]+[OrderChg]+[Label]+[Wrap]+[Labor]+[Rush]

页脚中的总公式

=Sum(IIf([Pkg] Like "*Large Drum*",[SQtyProd]*[DrmChrg],[SQtyPD]*[PltChrg])+[XPallet]+[OrderChg]+[Label]+[Wrap]+[Labor]+[Rush])

来自报告的SQL

SELECT DISTINCT tblShipping.SDate, tblShipping.shpOrder, tblShipping.shpSKU, tblShipping.shpSKU, tblShipping.shpLot, tblShipping.shpQtyProd, tblShipping.shpQtyPD, tblShipping.shpXPallet, tblShipping.shpOrderChg, tblShipping.shpLabel, tblShipping.shpLabel1, tblShipping.shpWrap, tblShipping.shpBand, tblShipping.shpLabor, tblShipping.shpLabor1, tblShipping.shpRush, tblPricing.*, tblProduct.*, tblInvoice.*
FROM tblPricing, tblInvoice, tblProduct INNER JOIN tblShipping ON tblProduct.SKU = tblShipping.[shpSKU]
WHERE (((tblShipping.SDate) Between [Forms]![frmInvoice]![ctrSDate] And [Forms]![frmInvoice]![ctrEDate]));

2 个答案:

答案 0 :(得分:0)

您当前的公式包含可能导致您的问题的权利。你现在拥有的是:

=Sum(IIf([Pkg] Like "*Large Drum*",[SQtyProd]*[DrmChrg],[SQtyPD]*[PltChrg])+[XPallet]+[OrderChg]+[Label]+[Wrap]+[Labor]+[Rush])

我建议尝试以下方法。虽然它应该产生与你拥有的相同的结果,但是你的工作不起作用(同样,对于后来的人来说,它的意图似乎更清楚):

=Sum(IIf([Pkg] Like "*Large Drum*",([SQtyProd]*[DrmChrg]+[XPallet]+[OrderChg]+[Label]+[Wrap]+[Labor]+[Rush]),([SQtyPD]*[PltChrg]+[XPallet]+[OrderChg]+[Label]+[Wrap]+[Labor]+[Rush])))

来自报告的SQL

SELECT DISTINCT tblShipping.SDate, tblShipping.shpOrder, tblShipping.shpSKU, tblShipping.shpSKU, tblShipping.shpLot, tblShipping.shpQtyProd, tblShipping.shpQtyPD, tblShipping.shpXPallet, tblShipping.shpOrderChg, tblShipping.shpLabel, tblShipping.shpLabel1, tblShipping.shpWrap, tblShipping.shpBand, tblShipping.shpLabor, tblShipping.shpLabor1, tblShipping.shpRush, tblPricing.*, tblProduct.*, tblInvoice.*
FROM tblPricing, tblInvoice, tblProduct INNER JOIN tblShipping ON tblProduct.SKU = tblShipping.[shpSKU]
WHERE (((tblShipping.SDate) Between [Forms]![frmInvoice]![ctrSDate] And [Forms]![frmInvoice]![ctrEDate]));

答案 1 :(得分:0)

我通过为页脚中的每个列创建总计,然后在总计字段中将它们一起添加来修复它。最后,我隐藏了那些标签,以免被人看到。