T
The Business Boy via AccessMonster.com
Hello.. I have the following aging query:
SELECT tblOrders.AcctNumber, tblOrders.InvoiceNumber, tblOrders.InvoiceDate,
IIf(DateDiff("d",InvoiceDate,Date())<=30,StorageCharges,0) AS [0-30], IIf
(DateDiff("d",InvoiceDate,Date())>30 And DateDiff("d",InvoiceDate,Date())<=60,
StorageCharges,0) AS [31-60], IIf(DateDiff("d",InvoiceDate,Date())>60 And
DateDiff("d",InvoiceDate,Date())<=90,StorageCharges,0) AS [61-90], IIf
(DateDiff("d",InvoiceDate,Date())>90,StorageCharges,0) AS [91+]
FROM tblOrders
WHERE StorageCharges <
(SELECT Sum(PaymentAmount)
FROM tblPayments as P
WHERE P.InvoiceNumber = TblOrders.InvoiceNumber)
OR Not Exists
(Select *
FROM tblPayments as P
WHERE P.InvoiceNumber = TblOrders.InvoiceNumber);
The query comes out fine except for the fact that if an invoice is not paid
in full, it doesn't show up on the query. Any type of payment will result in
the invoice not showing up on this query. Is there a way to modify this code
so that any remaining balance is show on this report.
Thank you... HAPPY NEW YEAR!
SELECT tblOrders.AcctNumber, tblOrders.InvoiceNumber, tblOrders.InvoiceDate,
IIf(DateDiff("d",InvoiceDate,Date())<=30,StorageCharges,0) AS [0-30], IIf
(DateDiff("d",InvoiceDate,Date())>30 And DateDiff("d",InvoiceDate,Date())<=60,
StorageCharges,0) AS [31-60], IIf(DateDiff("d",InvoiceDate,Date())>60 And
DateDiff("d",InvoiceDate,Date())<=90,StorageCharges,0) AS [61-90], IIf
(DateDiff("d",InvoiceDate,Date())>90,StorageCharges,0) AS [91+]
FROM tblOrders
WHERE StorageCharges <
(SELECT Sum(PaymentAmount)
FROM tblPayments as P
WHERE P.InvoiceNumber = TblOrders.InvoiceNumber)
OR Not Exists
(Select *
FROM tblPayments as P
WHERE P.InvoiceNumber = TblOrders.InvoiceNumber);
The query comes out fine except for the fact that if an invoice is not paid
in full, it doesn't show up on the query. Any type of payment will result in
the invoice not showing up on this query. Is there a way to modify this code
so that any remaining balance is show on this report.
Thank you... HAPPY NEW YEAR!