Trouble with Sum

  • Thread starter Thread starter Renee
  • Start date Start date
R

Renee

I have a calculated field in a report:

=fnDepreciation([EquipType], [InService], [YearNumber],
[Cost])

where fnDepreciation is a public function. The function
works well, but when I try to add a sum to my report I get
#Error. This is what I'm typing in the text box on the
report:

=Sum(fnDepreciation([EquipType], [InService],
[YearNumber], [Cost]))

I also tried getting the sum of the Cost with =Sum([Cost])
and also got #Error.

What am I doing wrong? Is it possible the Sum function is
not installed? If so, how do I install it?

Thanks for any help!
Renee
 
Thanks for your help. I took your advice and did the
calculation in the source query. So now, to get the sum
of the depreciation, I'm just putting in

=Sum([Depreciation])

but I still get #Error. This is the only #Error I'm
getting.

Any more ideas?
Renee

-----Original Message-----
Renee said:
I have a calculated field in a report:

=fnDepreciation([EquipType], [InService], [YearNumber],
[Cost])

where fnDepreciation is a public function. The function
works well, but when I try to add a sum to my report I get
#Error. This is what I'm typing in the text box on the
report:

=Sum(fnDepreciation([EquipType], [InService],
[YearNumber], [Cost]))

I also tried getting the sum of the Cost with =Sum ([Cost])
and also got #Error.

As long as the arguments are fields in the report's record
source table/query and not the names of controls on the
report, I don't know why you're getting #Error. The only
thing that comes to mind is that sometimes, if one aggregate
function generates #Error then others do too. Do you have
any other #Error showing?

I think you would be better off doing this calculation in
the report's record source query instead of doing it
repeatedly in the report. At least the Sum would be much
faster/simpler.
 
I did have a text box with the name "Depreciation" but I
changed it and am still getting #Error.

I'm stumped.

Renee
 
Renee said:
I did have a text box with the name "Depreciation" but I
changed it and am still getting #Error.

I'm beginning to suspect the function. Open the report's
record source query from the query window, then scan down
the calculated field to see if every row has a valid value.
I think you'll find that at least one record has #Error. If
so, look at the fields that are used in the function's
arguments and make sure they conform to the data type and
range that the function expects. A common problem of this
nature is that you declared one of the function's argument
to be a specific type (e.g. Date, Currency, etc.), but the
value passed to the function is Null.
 
Did you ever suggest which section the text box is contained in? Make sure
the text box with the Sum() is not in the Page Footer.
 
Duane said:
Did you ever suggest which section the text box is contained in? Make sure
the text box with the Sum() is not in the Page Footer.

Way to go Duane!
 
Duane said:
Maybe I have made this mistake before... I am not admitting to anything
though.

LOL!

Never having made that mistake myself explains why I didn't
think of it. <gdr>
 
Back
Top