Hi,
I am reviewing some terrible old database methods and was wondering the best way to achieve a text box containing the sum of values for items between two dates. At present it is done using a sub-form based on a query of a query.
At first a query collects the values between dates:
and then a secondary query generates the sum of the values:
This actually works perfectly but needs two queries and a sub-form for each bit of information and there twelve of them (quotes, orders and invoices for last 3, 6, 9 and 12 months).
I am reviewing some terrible old database methods and was wondering the best way to achieve a text box containing the sum of values for items between two dates. At present it is done using a sub-form based on a query of a query.
At first a query collects the values between dates:
Code:
SELECT tblDespatch.Invoiced, tblOrders.Value
FROM tblOrders INNER JOIN tblDespatch ON tblOrders.ID = tblDespatch.JobDespatchID
WHERE (((tblDespatch.Invoiced) Between (DateAdd("m",-3,Date())) And Date()));
and then a secondary query generates the sum of the values:
Code:
SELECT Sum(qrySWBI03.Value) AS SumOfValue
FROM qrySWBI03;
This actually works perfectly but needs two queries and a sub-form for each bit of information and there twelve of them (quotes, orders and invoices for last 3, 6, 9 and 12 months).