Error value in calculated control when no records

G

Guest

I have a report that has a textbox in the footer that is using the sum aggregate function to calculate a total price
If there are records, the calculated field works fine. If there are no records, the calculated control shows a
#Error value in the control

I have a form that does the same thing, but it does not give an error. It is just Null
 
A

Allen Browne

The simplest way to avoid this is to cancel the report's NoData event.

If you prefer, you can use the HasData property of the report in the
ControlSource of the text box:
=IIf([Report].[HasData], Sum([MyField]), Null)

The reason forms behave differently is that they go to a new record. A form
that cannot accept new records (e.g. if its AllowAdditions property is No)
gives the error like the report does when you refer to something that does
not exist.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Kathy said:
I have a report that has a textbox in the footer that is using the sum
aggregate function to calculate a total price.
If there are records, the calculated field works fine. If there are no
records, the calculated control shows an
 

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