Subreport - make invisible in Report View

Dear experts -
I have a subreport which I would like to make invisible if it contains no records - it does this OK in Print Preview, but NOT in Report View.
Any ideas?
Thanks!
terpsichoreAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IrogSintaCommented:
Put a textbox in the header or footer of your subreport and in its ControlSource insert this:
=Count (*)
Let's call it txtCount.  Then in the OnLoad event of your report, add this:
Me.NameOfSubreportControl.Visible = (Me.NameOfSubreportControl.Report!txtCount > 0)
0
terpsichoreAuthor Commented:
i want the subreport to be visible or not depending on the value of the parent record.
For example, we have:
Project 1
- subreport may be visible or not
Project 2
- subreport may be visible or not
Project 3
- subreport may be visible or not

Will this work in that case?
0
IrogSintaCommented:
Looks like you have this subreport in the Detail section.  Normally you would put the code in the OnFormat property of the Detail section; however, this will only work in Print Preview and when printing the report.  It will not work in Report View.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

terpsichoreAuthor Commented:
there is no workaround?
0
IrogSintaCommented:
Unfortunately, in Report View, many of the events do not fire.  The only formatting event that fires in this view is OnPaint; however, you cannot change the visibility property of a control in this event.

The only work around I can think of is to not have any header or footer in the subreport.  In other words, the subreport should only have the Detail section.  Any label headings should be in the header section of the main report.  I'm just not sure if this would work for you.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
terpsichoreAuthor Commented:
extremely thorough. thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.