showing nothing if no data in subreport

Sam Summers

Registered User.
Local time
Today, 18:30
Joined
Sep 17, 2001
Messages
939
I have tried numerous ideas as posted in the forum, but still no joy!

I have a main report (Manifest) that has numerous sub-reports in it e.g. MaillonLocation.
In the subreport I have an unbound textbox (Mtotal) that holds the total of records in the subreport based on the bound textbox (ItemNo), by using - =Count([MaillonLocation]![ItemNo]).
On the main report I have an unbound textbox (Mcalc) that displays the total number of records in the subreport by using - =([MaillonLocation]![Mtotal].[Text]).

What I want to do is display nothing on the Main report textbox if there is no data in the subreport.

I have tried this - =IIf([MaillonLocation].[Report].[HasData],"","").
But this simply displays nothing all the time.
The rest of the time, all I am getting is #Error.

Great if you can help me.

Thanks in advance
 
I don't know that your references are actually valid, but I see one big problem right away with:
Code:
=Iif([MaillonLocation].[Report].[HasData],"","")
The reason it prints blank all the time is that you have both your true AND false values set to "", as the syntax for Iif is:
Code:
=Iif(<<test>>, <<value if test results TRUE>>, <<value if test results FALSE>>)
So, try something more like:
Code:
=Iif([MaillonLocation].[Report].[HasData], [MaillonLocation]![Mtotal].[Text], "")

As far as the references go, did you build them or just type them in?
 
Thanks for the swift reply.

I wasn't sure about the structure of the statement as I haven't done this before.

The references are fine I think, as I have tried using the builder and they worked fine before when there is data in the subreport, its only now that I'm trying to get rid of #Error being printed if there is no data in a subreport.

I'll try your suggestion tomorrow and if I have any further problems, I'll post my findings here later on tomorrow.

Thanks very much
 
Sam-- Still no time to experiment with this, but it occurs to me to check and make sure you're not encountering difficulties relating to the differences between how Access handles 0's, Null's, and blank fields. Check Access Help on that #Error message and also read the help pertaining to the IsNull and Nz statements.

--Harried Mac
 
Thanks Mac,

I tried your previous code and it seems to be working fine now - i.e. displaying nothing if no data in the subreports and displaying the record number if there are records in the subreports.

Perfect

Thanks
 
Might it be easier to use the No Data event for the subreport to do this???
 
Hi Jerry,

I think I tried that before but couldn't get it to work properly.

What statement do you propose?
 

Users who are viewing this thread

Back
Top Bottom