I can get this to work in Access but I can't use the DMax and DSum statements in VB6 because of DAO, so I was told to use a subquery. Can anyone help me convert this over to use a subquery (using Max and Sum instead) instead?
Recap of what is happening...My joined tables have multiple lines/rows for an item (DrawHdrID), and I need to collapse them all into one single line PER DrawHdrID, and show the highest number of one column (Request number) and the total of another column (Contract amount)PER DrawHdrID. I have been looking at this for days trying to figure out the syntax but I can't seem to get it right. Thanks in advance for any help that you can give in this issue!
SELECT JCDrHdr.DrawHdrID, JCDrHdr.ReqNo AS Request, JCDrHdr.PrjNo AS Project, JCDrHdr.JobNo AS Job, JCDES.DesName AS JobName, JCDES.DesLoNo AS LotNo, DSum('RevConAmt','JCDrDtl','DrawHdrID=' & [JCDrHdr].[DrawHdrID] & ' And DrawNo=' & DMax('ReqNo','JCDrHdr','DrawHdrID=' & [JCDrHdr].[DrawHdrID] & '')) AS ContractTotal
FROM (JCDrLndr RIGHT JOIN (JCDrHdr INNER JOIN JCDrDtl ON JCDrHdr.DrawHdrID = JCDrDtl.DrawHdrID) ON JCDrLndr.LenderID = JCDrHdr.LenderID) LEFT JOIN JCDES ON (JCDrHdr.JobNo = JCDES.DesJbNo) AND (JCDrHdr.PrjNo = JCDES.DesPrNo)
GROUP BY JCDrHdr.DrawHdrID, JCDrHdr.ReqNo, JCDrHdr.PrjNo, JCDrHdr.JobNo, JCDES.DesName, JCDES.DesLoNo
HAVING (((JCDrHdr.ReqNo)=DMax('ReqNo','JCDrHdr','
DrawHdrID=' & [JCDrHdr].[DrawHdrID] & '')))
Recap of what is happening...My joined tables have multiple lines/rows for an item (DrawHdrID), and I need to collapse them all into one single line PER DrawHdrID, and show the highest number of one column (Request number) and the total of another column (Contract amount)PER DrawHdrID. I have been looking at this for days trying to figure out the syntax but I can't seem to get it right. Thanks in advance for any help that you can give in this issue!
SELECT JCDrHdr.DrawHdrID, JCDrHdr.ReqNo AS Request, JCDrHdr.PrjNo AS Project, JCDrHdr.JobNo AS Job, JCDES.DesName AS JobName, JCDES.DesLoNo AS LotNo, DSum('RevConAmt','JCDrDtl','DrawHdrID=' & [JCDrHdr].[DrawHdrID] & ' And DrawNo=' & DMax('ReqNo','JCDrHdr','DrawHdrID=' & [JCDrHdr].[DrawHdrID] & '')) AS ContractTotal
FROM (JCDrLndr RIGHT JOIN (JCDrHdr INNER JOIN JCDrDtl ON JCDrHdr.DrawHdrID = JCDrDtl.DrawHdrID) ON JCDrLndr.LenderID = JCDrHdr.LenderID) LEFT JOIN JCDES ON (JCDrHdr.JobNo = JCDES.DesJbNo) AND (JCDrHdr.PrjNo = JCDES.DesPrNo)
GROUP BY JCDrHdr.DrawHdrID, JCDrHdr.ReqNo, JCDrHdr.PrjNo, JCDrHdr.JobNo, JCDES.DesName, JCDES.DesLoNo
HAVING (((JCDrHdr.ReqNo)=DMax('ReqNo','JCDrHdr','
DrawHdrID=' & [JCDrHdr].[DrawHdrID] & '')))