Control result '0' needed when no subreport

Gkirkup

Registered User.
Local time
Today, 12:56
Joined
Mar 6, 2007
Messages
628
I have a report with a subreport. On the subreport is an invisible =Sum([Myfield]) control. Then on the main form, another control shows whatever is in that subreport control.
The subreport is driven by a query. My problem is that when the query returns nothing, the subreport doesn't display, and my control on the main form shows 'Error'.
I got around this by using a Dlookup() on a new query which returns the total that I need, for my control on the main report. So no more 'Error'. However, when there are no records, Dlookup() doesn't return '0', but nothing. I tried NZ(Dlookup()) but still nothing. I need to have a '0' in the control on the main report when there are no records, as that is part of a total. How do I get '0' when there are no records returned by the query?

Robert
 
Re: Control result '0' needed when no subform

Pbaldy: That worked perfectly. Thanks so much.

Robert
 
Happy to help Robert.
 
Just a newbie asking a question..

Couldn't you just assign a default value of 0 in the general field properties?
 
Don't think so, but give it a try and let us know.
 

Users who are viewing this thread

Back
Top Bottom