How to total calculated fields

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
 
K

KARL DEWEY

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.
 
D

Douglas J. Steele

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
 
J

John W. Vinson

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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top