April15Hater
Accountant
- Local time
- Yesterday, 23:29
- Joined
- Sep 12, 2008
- Messages
- 349
What I am trying to do is list all of the TRecsaccount data and the corresponding counts and sums of debits and credits separated out into columns. Each record is notated DR or CR in the DRCR field for Debits and Credits respectively.
What I did was made a query grouped by TRecsaccount, and made an expression using a conditional to bifurcate the DR's and CR's into seperate fields and then summed and counted in 2 separate fields accordingly. The problem is that the amounts in DR and CR should be different, but they are not.
What I did was made a query grouped by TRecsaccount, and made an expression using a conditional to bifurcate the DR's and CR's into seperate fields and then summed and counted in 2 separate fields accordingly. The problem is that the amounts in DR and CR should be different, but they are not.
Code:
SELECT tblAcctTranslation.TRECSAccount,
IIf("DRCR='DR'",Sum([Amount]),0) AS DRAmt,
IIf("DRCR='CR'",Sum([Amount]),0) AS CRAmt,
IIf("DRCR='DR'",Count([Amount]),0) AS DRCount,
IIf("DRCR='CR'",Count([Amount]),0) AS CRCount
FROM tblAcctTranslation INNER JOIN TLP_Outstanding ON tblAcctTranslation.ImportAccountwName = TLP_Outstanding.ImportAccount
GROUP BY tblAcctTranslation.TRECSAccount
ORDER BY tblAcctTranslation.TRECSAccount;