Conditional Sum Problem...

K

killjoy966

I'm a little new to Access but I'm trying to slug my way through with
little in the way of guidance. I'm trying to sum a column of dollar
amounts based on a code in a "Results" column. Now, I saw various
suggestions and I understand the logic behind them, but when I plug it
in, not only does it not work, but it also causes an error in another
field I have that totals the absolute sum (no conditions).

TotalCharged: =Sum([Amount])

TotalRecovered: =Sum(IIf([Amount]="Paid",[Amount],0))

I suppose it should be noted that these fields are hidden in a subform
and referenced by the main form. These are the display calls:

[Charges Subform]!TotalCharged

[Charges Subform]!TotalRecovered

Is there something obvious that I'm missing here?

- MTH
 
K

KARL DEWEY

Is there something obvious that I'm missing here?
Yep. Below you are add up the field named Amount so it is a numerical field.
TotalCharged: =Sum([Amount])
Below you are asking if the field Amount containd the word "Paid" and then
total it. A numerical field can not contain text.
TotalRecovered: =Sum(IIf([Amount]="Paid",[Amount],0))
 
K

killjoy966

I always get hung up on things like that. But I have a quick follow-up
question: why would that alter the result of TotalCharged. I didn't
even touch it but when I made TotalRecovered, both fields showed
"#Error"?

-MTH
 
K

KARL DEWEY

It could be hidden in your statement "I suppose it should be noted that
these fields are hidden in a subform and referenced by the main form." Yhat
I did not follow.

What does it mean?
 
Top