Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

don't want subreport to disappear when there's no data 2

Status
Not open for further replies.
Jan 14, 2002
143
0
0
US
My subreport disappears when there's no data. I don't want it to do this because the report's design is a standard form in the industry, so it must always look the same...and when my subreport disappears so does about half of my standard form! How can I prevent it from doing this?

Thank you
 
Did you ever figure out how to take care of this?

I have several subreports on my main report and each has a label that says "There are no errors in this category". On each of my subreports, I've set the visible property for this label to false in the Open event. I set the visible property for this label to true in the NoData event and all other labels to false.

This works if I open the subreports individually but, if I open the main report it does not work. (i.e., If a given subreport has no data nothing is displayed -- no data and no label saying that "there are no errors in this category".

I've got a feeling that I need to write some code on the main report referencing the visible property of controls in the subreports but I'm not sure which event to code.

Ann
 
Hi Ann, gee, it's been a year, right on the nose nearly, since I had that problem...honestly I don't think I ever got that one figured out. It seems like I resorted to a pretty dirty solution and put the labels on the main report instead.

You have a good idea referencing the label from the main report, although I can't say whether it will work. I'd try either the open or load event.

Good luck
-Blaine








 
If there is no data on the subreport, you can't make it display. Subreports don't support page headers and footers. If you need stuff to display over a specific area of a main report, you will need to size the subreport control and don't allow it to either grow or shrink. You can then add controls/labels on the main report that can be made visible if the subreport has no data. The code would be something like:

Me.lblA.Visible = Not Me.sbrptControl.Report.HasData
Me.lblB.Visible = Not Me.sbrptControl.Report.HasData
Me.lblC.Visible = Not Me.sbrptControl.Report.HasData
Me.lineD.Visible = Not Me.sbrptControl.Report.HasData


Duane
MS Access MVP
 
I created a label on the main report and added this line to the main report's open event:

Me.lblNoDataMessage.Visible = Not Me.rptFindErrorsDivision.Report.HasData

When I try to display the main report I get this error:
"Run-time error 2455: You entered an expression that has an invalid reference to the property Form/Report" and the code above is highlighted.

rptFindErrorsDivision is the name of the subreport control and the source object for the subreport is rptFindErrorsDivisionOrContract

Can you see what I'm doing wrong?

Ann
 
Try place your code in the On Format event of the section containing lblNoDataMessage.

Duane

Duane
MS Access MVP
 
Duane, I tried that but now I'm getting error #450 (wrong number of arguments or invalid property assignment).

Any thoughts?

Ann
 
I would like to see your full code. Otherwise you could possibly get rid of the code by using a text box with a control source of:
=IIF(rptFindErrorsDivision.Report.HasData,"", "text to display")


Duane
MS Access MVP
 
Duane, I decided to go with your iif statement which works like a charm.

Thanks for hanging in there with me!

Ann
 
Hey guys, sorry for bothering ... I posted a question already, but no one has seemed to answer (thread703-605847) .... and this seems like the closest topic I could find.

How do you open a report that has subreports when you want to open the report with criteria thats based on the sub-report? I can open the report fine with criteria for the main report, but I always get a prompt asking me to input data for the field that I'm searching for in my sub-report. Sorry for intruding on your topic ... I just really need help. Any advice or suggestions would be most appreciated. Thnx. (^_^)

-Jedi420
 
Check back to your original thread.

Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top