G
graeme34 via AccessMonster.com
Hi could somebody help me out adapting the following query.....
I currently have a statement report that has a subreport of all linked to the
main report by account name....
The subreport has a detail line for each Invoice sent through the month...as
the enterprise rules are payment 30 days from end of month.... there can be
three months of invoices to the customer in the report....also in the detail
section are control boxes showing any payments received for those invoices
with the can shrink property set to yes...since bringing the payment details
into the report my footer section has hit a snag...I orginally planned a
sub/sub report in the footer showing the total invoiced amount for each month
with the control source query as such:
SELECT DISTINCT qryStatementLine.AccountIndex, Format([InvoiceDate],"mmmm")
AS MonthName, Sum(qryStatementLine.Debit) AS SumOfDebit, DatePart("m",
[InvoiceDate]) AS MonthNumber
FROM qryStatementLine
GROUP BY qryStatementLine.AccountIndex, Format([InvoiceDate],"mmmm"),
DatePart("m",[InvoiceDate])
ORDER BY qryStatementLine.AccountIndex, DatePart("m",[InvoiceDate]) DESC;
Which as you can see Selects and groups the account index and sums all debits
in each month.
This worked fine(ish)
Ideally I would have liked the report to also show the month if the customer
hadnt ordered anything. ie.
March £543.04
February £ 0.00
January £182.45
Whereas currently it is only showing March and January....I not too sure this
is a query problem as there is nothing to select....I'm thinking more along
the line of conditions built into the report format....but not sure how to
got about this...thats one problem.
My main problem is when I have tried to bring payment details into the query,
if a customer has made more than one payment in that month then I am getting
(n) number of records for each month sum, here is the adapted query:
SELECT DISTINCT qryMonthSalesCust.AccountIndex, qryMonthSalesCust.MonthName,
qryMonthSalesCust.SumOfDebit, qryMonthSalesCust.MonthNumber, tblTransaction.
TransCredit
FROM tblTransaction INNER JOIN ((tblSalesOrder INNER JOIN qryMonthSalesCust
ON tblSalesOrder.AccountIndex = qryMonthSalesCust.AccountIndex) INNER JOIN
(tblDespatch INNER JOIN tblSalesInvoice ON tblDespatch.DespatchNumber =
tblSalesInvoice.[Despatch Number]) ON tblSalesOrder.SalesOrderNumber =
tblDespatch.SalesOrderNumber) ON tblTransaction.TransactionNumber =
tblSalesInvoice.TransactionNumber
ORDER BY qryMonthSalesCust.AccountIndex, qryMonthSalesCust.MonthNumber DESC;
Where TransCredit is the amount of any payments made..
But the results are nothing like I had planned...although I can see why it
showing them...
just dont know how to rectify it
I currently have a statement report that has a subreport of all linked to the
main report by account name....
The subreport has a detail line for each Invoice sent through the month...as
the enterprise rules are payment 30 days from end of month.... there can be
three months of invoices to the customer in the report....also in the detail
section are control boxes showing any payments received for those invoices
with the can shrink property set to yes...since bringing the payment details
into the report my footer section has hit a snag...I orginally planned a
sub/sub report in the footer showing the total invoiced amount for each month
with the control source query as such:
SELECT DISTINCT qryStatementLine.AccountIndex, Format([InvoiceDate],"mmmm")
AS MonthName, Sum(qryStatementLine.Debit) AS SumOfDebit, DatePart("m",
[InvoiceDate]) AS MonthNumber
FROM qryStatementLine
GROUP BY qryStatementLine.AccountIndex, Format([InvoiceDate],"mmmm"),
DatePart("m",[InvoiceDate])
ORDER BY qryStatementLine.AccountIndex, DatePart("m",[InvoiceDate]) DESC;
Which as you can see Selects and groups the account index and sums all debits
in each month.
This worked fine(ish)
Ideally I would have liked the report to also show the month if the customer
hadnt ordered anything. ie.
March £543.04
February £ 0.00
January £182.45
Whereas currently it is only showing March and January....I not too sure this
is a query problem as there is nothing to select....I'm thinking more along
the line of conditions built into the report format....but not sure how to
got about this...thats one problem.
My main problem is when I have tried to bring payment details into the query,
if a customer has made more than one payment in that month then I am getting
(n) number of records for each month sum, here is the adapted query:
SELECT DISTINCT qryMonthSalesCust.AccountIndex, qryMonthSalesCust.MonthName,
qryMonthSalesCust.SumOfDebit, qryMonthSalesCust.MonthNumber, tblTransaction.
TransCredit
FROM tblTransaction INNER JOIN ((tblSalesOrder INNER JOIN qryMonthSalesCust
ON tblSalesOrder.AccountIndex = qryMonthSalesCust.AccountIndex) INNER JOIN
(tblDespatch INNER JOIN tblSalesInvoice ON tblDespatch.DespatchNumber =
tblSalesInvoice.[Despatch Number]) ON tblSalesOrder.SalesOrderNumber =
tblDespatch.SalesOrderNumber) ON tblTransaction.TransactionNumber =
tblSalesInvoice.TransactionNumber
ORDER BY qryMonthSalesCust.AccountIndex, qryMonthSalesCust.MonthNumber DESC;
Where TransCredit is the amount of any payments made..
But the results are nothing like I had planned...although I can see why it
showing them...
just dont know how to rectify it