Re: Calculating two fields on based of the value of one field
- From: "Carl Rapson" <mr.mxyzptlk@xxxxxxxxxxxxxxxxx>
- Date: Fri, 27 Apr 2007 10:47:25 -0500
Is that query working? If so, it looks like you already have your Credit and
Debit totals. What problem are you having?
Carl Rapson
"Daljeet Bajwa" <DaljeetBajwa@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:05609CDD-C5F0-41FC-8ED8-CC931DA60E1C@xxxxxxxxxxxxxxxx
Thanks Carl but I forget clarify my question. First of all, here is my SQL
Statement :
SELECT tblAtlantic.[Cardholder Name], "************" &
Right(tblAtlantic.[Card Number],4) AS [Secured Number],
tblAtlantic.[Accounting Code], tblAtlantic.[Merchant Name] & " " &
tblAtlantic.[MCC code] AS Merchant, Left(tblAtlantic![Posting Date],4) &
"/"
& Mid(tblAtlantic![Posting Date],5,2) & "/" & Right(tblAtlantic![Posting
Date],2) AS [Formatted Posting Date], tblAtlantic.[Gross Amount],
tblAtlantic.[National Tax], tblAtlantic.[Net Amount],
Left(tblAtlantic![Cycle
Date],4) & "/" & Mid(tblAtlantic![Cycle Date],5,2) & "/" &
Right(tblAtlantic![Cycle Date],2) AS [Formatted cycle Date],
IIf(Left(tblAtlantic.[Gross Amount],1)="-","C","D") AS [Credit Status],
DSum(tblAtlantic.[Gross Amount],"tblAtlantic",[Credit Status]='C') AS
[Total
Credits], DSum(tblAtlantic.[Gross Amount],"tblAtlantic",[Credit
Status]='D')
AS [Total Debits]
FROM tblAtlantic;
I am using this query for a report and on my report I need two separate
totals for credits and debits. Any help will greatly appreciated. Thanks.
Regards
"Carl Rapson" wrote:
"Daljeet Bajwa" <DaljeetBajwa@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9A62D82C-E44B-45F7-9B31-BA6A038CBBC3@xxxxxxxxxxxxxxxx
My table has a amount field which contains Credits and debits. I have
another
field which has two values C for Credit and D for Debit.
I would like to sum up both credits and debits into two different
fields.
How can I accomplish that? Thanks.
Credits = DSum("Amount", "MyTable","AnotherField='C'")
Debits = DSum("Amount","MyTable","AnotherField='D'")
Note the single quotes around the C and D in the third parameter. Be sure
to
use you own field and table names.
Carl Rapson
.
- References:
- Re: Calculating two fields on based of the value of one field
- From: Carl Rapson
- Re: Calculating two fields on based of the value of one field
- Prev by Date: Re: NEED A SINGLE RECORD RETURNED FROM ONE TO MANY QUERY
- Next by Date: Re: Trim Data
- Previous by thread: Re: Calculating two fields on based of the value of one field
- Next by thread: Re: Missing Index
- Index(es):
Relevant Pages
|