Thanks to both for replying.
The first query totals invoice on a daily basis: count, sum of sales and
sum
of cost. The second query will then add a count field of records, gross
profit and %, invoice avg $ on the daily record and also a running MTD
total
for all fields. I put the month criteria in the first query due to a
quick
statement method for the DCount for totaling the running day of the month
in
the second query. Also for the number of records I thought the
query/forms
would run quicker (approx. 500 to 800 new records a month) if I limited
the
records going into calculations.
My first query SQL:
SELECT Count(tblInvoices.InvoiceNumber) AS CountOfInvoiceNumber,
tblInvoices.
Date, Sum(tblInvoices.InvoiceSale) AS SumOfInvoiceSale, Sum(tblInvoices.
InvoiceCost) AS SumOfInvoiceCost, DatePart("d",[Date]) AS ADay,
DatePart("m",
[Date]) AS AMonth, DatePart("yyyy",[Date]) AS AYear
FROM tblInvoices
GROUP BY tblInvoices.Date, DatePart("d",[Date]), DatePart("m",[Date]),
DatePart("yyyy",[Date])
HAVING (((tblInvoices.Date) Between
DateSerial(Year(Date()),Month(Date())-1,1)
And DateSerial(Year(Date()),Month(Date()),0)));
My second query SQL:
SELECT qselInvoiceTotalDate.Date,
DCount("*","qselInvoiceWorkDayTotal","[Date]
<=#" & [Date] & "#") AS [Day#], qselInvoiceTotalDate.SumOfInvoiceSale,
qselInvoiceTotalDate.SumOfInvoiceCost,
[SumOfInvoiceSale]-[SumOfInvoiceCost]
AS Gross, [Gross]/[SumOfInvoiceSale] AS [Gross %], qselInvoiceTotalDate.
CountOfInvoiceNumber, [SumOfInvoiceSale]/[CountOfInvoiceNumber] AS [Inv
Avg $]
, CCur(DSum("SumOfInvoiceSale","qselInvoiceTotalDate","DatePart('d',
[Date])
<=" & [ADay] & " And DatePart('m', [Date])=" & [AMonth] & " And DatePart
('yyyy', [Date])=" & [AYear] & "")) AS [MTD Sale], CCur(DSum
("SumOfInvoiceCost","qselInvoiceTotalDate","DatePart('d', [Date])<=" &
[ADay]
& " And DatePart('m', [Date])=" & [AMonth] & " And DatePart('yyyy',
[Date])="
& [AYear] & "")) AS [MTD Cost], [MTD Sale]-[MTD Cost] AS [MTD Grs Prf],
[MTD
Grs Prf]/[MTD Sale] AS [MTD Grs %], DSum("CountOfInvoiceNumber",
"qselInvoiceTotalDate","DatePart('d', [Date])<=" & [ADay] & " And DatePart
('m', [Date])=" & [AMonth] & " And DatePart('yyyy', [Date])=" & [AYear] &
"")
AS [MTD # Inv], [MTD Sale]/[MTD # Inv] AS [MTD Inv Avg $]
FROM qselInvoiceTotalDate
ORDER BY qselInvoiceTotalDate.Date;
Is this possible in a form without a slow return on the calculations?
This
is the reason I thought two command buttons would be the best route, one
for
current month and set as default and second for the prior month.
Thanks again,
Bill Fischer
Duane said:
You should use controls on forms as your criteria in queries. When you
want
to update the records displayed in a form, use code like:
Me.Requery
Is what I'm trying to do possible? I have a form based off a query
which
in
[quoted text clipped - 11 lines]