How to total calculated fields

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I am calculating my "Line" total like this:

=IIf([ChargeDays]="","",[ChargeDays]*[PerDiemRate])
in a field called "txtTotal"

To get a total of line items I have tried these:

=Sum([txtTotal])
=Sum([ChargeDays]*[PerDiemRate])
=Sum(([ChargeDays]*[PerDiemRate]))
=sum((IIf([ChargeDays]="","",[ChargeDays]*[PerDiemRate])))

all if these give me "#error"
regardless if the list is filtered or not filtered

Any help here will be appreciated.

Thanks in advance
 
It is hard to sum text.

Try this ---
=sum((IIf([ChargeDays]=Null,0,[ChargeDays]*[PerDiemRate])))
OR
=sum((IIf([ChargeDays]=0,0,[ChargeDays]*[PerDiemRate])))
based on whether you have nulls or blanks.
 
Slight correction. If ChargeDays can be Null, you'd want

=Sum(IIf(IsNull([ChargeDays]),0,[ChargeDays]*[PerDiemRate]))

or

=Sum(Nz([ChargeDays], 0)*[PerDiemRate])

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


KARL DEWEY said:
It is hard to sum text.

Try this ---
=sum((IIf([ChargeDays]=Null,0,[ChargeDays]*[PerDiemRate])))
OR
=sum((IIf([ChargeDays]=0,0,[ChargeDays]*[PerDiemRate])))
based on whether you have nulls or blanks.
--
KARL DEWEY
Build a little - Test a little


Dave said:
I am calculating my "Line" total like this:

=IIf([ChargeDays]="","",[ChargeDays]*[PerDiemRate])
in a field called "txtTotal"

To get a total of line items I have tried these:

=Sum([txtTotal])
=Sum([ChargeDays]*[PerDiemRate])
=Sum(([ChargeDays]*[PerDiemRate]))
=sum((IIf([ChargeDays]="","",[ChargeDays]*[PerDiemRate])))

all if these give me "#error"
regardless if the list is filtered or not filtered

Any help here will be appreciated.

Thanks in advance
 
None of either of your suggestions worked.
Am I doing something else wrong?

Presumably. What are you doing? I can't see it from here.

John W. Vinson [MVP]
 
Back
Top