B
Brad
Here's my query so far:
SELECT DL.CustID AS CustID, DL.FullName AS FullName,
DL.LoanID AS LoanID, DL.DateIssued AS DateIssued,
DL.DueDate AS DueDate, DL.Balance AS Balance, DL.OrigBal
AS OrigBal, CA.DateAssigned, IIf(CA.DateAssigned Is Not
Null,IIf(Max(C.DateofCall)>CA.DateAssigned,Max
(C.DateofCall),''),'') AS LastCall, IIf(CA.DateAssigned
Is Not Null,Sum(P.Amount),0) AS Collected
FROM ((qryDelinquentLoan AS DL LEFT JOIN
tblCallAssignment AS CA ON CA.CustID=DL.CustID) LEFT JOIN
tblCalls AS C ON DL.LoanID=C.LoanID) LEFT JOIN
tblPayments AS P ON DL.LoanID=P.LoanID
WHERE (CA.DateAssigned Is Not Null And
P.Date>CA.DateAssigned And P.Deleted=False) Or
(CA.DateAssigned Is Null)
GROUP BY DL.CustID, DL.FullName, DL.LoanID,
DL.DateIssued, DL.DueDate, DL.Balance, DL.OrigBal,
CA.DateAssigned, DL.LoanID
ORDER BY DL.CustID;
I run into trouble with tblPayments (P). I want the
query to return the sum of all payments after a certain
date (P.Date > CA.DateAssigned) but if there have been no
payments after that date, return 0 (there have most
likely been payments before that date.) Currently, if
there are no payments after the date, the records drop
out of the query. I tried to add P.Date to a nested IIF
statement in the select "IIf(CA.DateAssigned Is Not Null,
IIF(P.[Date] > CA.DateAssigned, Sum(P.Amount),0), 0) AS
Collected," but then I had to add P.Date to the Group By
and the query returned a record for every payment in the
table (even records prior to the DateAssigned), rather
than one record with a sum. Any way to get this to work?
Thanks
SELECT DL.CustID AS CustID, DL.FullName AS FullName,
DL.LoanID AS LoanID, DL.DateIssued AS DateIssued,
DL.DueDate AS DueDate, DL.Balance AS Balance, DL.OrigBal
AS OrigBal, CA.DateAssigned, IIf(CA.DateAssigned Is Not
Null,IIf(Max(C.DateofCall)>CA.DateAssigned,Max
(C.DateofCall),''),'') AS LastCall, IIf(CA.DateAssigned
Is Not Null,Sum(P.Amount),0) AS Collected
FROM ((qryDelinquentLoan AS DL LEFT JOIN
tblCallAssignment AS CA ON CA.CustID=DL.CustID) LEFT JOIN
tblCalls AS C ON DL.LoanID=C.LoanID) LEFT JOIN
tblPayments AS P ON DL.LoanID=P.LoanID
WHERE (CA.DateAssigned Is Not Null And
P.Date>CA.DateAssigned And P.Deleted=False) Or
(CA.DateAssigned Is Null)
GROUP BY DL.CustID, DL.FullName, DL.LoanID,
DL.DateIssued, DL.DueDate, DL.Balance, DL.OrigBal,
CA.DateAssigned, DL.LoanID
ORDER BY DL.CustID;
I run into trouble with tblPayments (P). I want the
query to return the sum of all payments after a certain
date (P.Date > CA.DateAssigned) but if there have been no
payments after that date, return 0 (there have most
likely been payments before that date.) Currently, if
there are no payments after the date, the records drop
out of the query. I tried to add P.Date to a nested IIF
statement in the select "IIf(CA.DateAssigned Is Not Null,
IIF(P.[Date] > CA.DateAssigned, Sum(P.Amount),0), 0) AS
Collected," but then I had to add P.Date to the Group By
and the query returned a record for every payment in the
table (even records prior to the DateAssigned), rather
than one record with a sum. Any way to get this to work?
Thanks