How to ask a field if it is #Error?

J

Jim Aga

I simply need to add the totals from my 4 subreports on my
main report. If any of the subreports have no data the
subtotal is #Error and that's OK but then the grand Total
is #Error.

There is no default property so I can't set it to zero.
The totals are unbound so there are no table field
defaults available to set to zero.

I've tried NZ(fieldname)on the main report and it doesn't
work when there is no data. I've also tried this on the
supreport's detail and total lines and that doesn't work.

If I could trap #Error i'd just do math in a separate
control box but how ??

Thanks In Advance
 
M

Marshall Barton

Jim said:
I simply need to add the totals from my 4 subreports on my
main report. If any of the subreports have no data the
subtotal is #Error and that's OK but then the grand Total
is #Error.

There is no default property so I can't set it to zero.
The totals are unbound so there are no table field
defaults available to set to zero.

I've tried NZ(fieldname)on the main report and it doesn't
work when there is no data. I've also tried this on the
supreport's detail and total lines and that doesn't work.

If I could trap #Error i'd just do math in a separate
control box but how ??

You could use the IsError function to check if a value is
#Error, but in this case, I think it's better to check if
the subreport doesn't have any data. Instead of using terms
like:

=subrpt.Report.textbox + ...

use

=IIf(subrpt.Report.HasData, subrpt.Report.textbox, 0) + ...
 
S

SA

Jim:

There really is no way to trap #Error. So you've go to use a different
approach to coming up with your grand total.

You could do this using VBA with something like this in the section of the
report that contains the grand total control (now unbound)

Dim lngTotalVal&
If Me.MySub1.HasData = True Then
lngTotalVal = lngTotalVal + Me!MySub1.Report!Sub1SubTotal
end if
If Me.MySub2.HasData = True Then
etc, etc.

Me!MyGrandTotal = lngTotalVal

HTH
 

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