Link to home
Create AccountLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Subreport will not shrink

I am having a lot of trouble getting a sub-report to shrink on a report if there is no data in the sub-report.  Therefore, the sub-report takes up a lot of room on the report leaving big gaps.  I have the text boxes set to Can Shrink = Yes.  I have made sure nothing overlaps.  I've made sure all objects are snapped to the grid.  On and on and on.

So now my question is...  Is there a way to make the height of the detail section be 0 if there is no data in the textbox and then bring it back to .1667 when the report is closed?
Avatar of bfuchs
Flag of United States of America image

make sure all the sections of the sub report are set to can shrink = yes.
the sub report itself on the main report should be set can shrink = yes.
and the section on the main report where the sub report is located should be set can shrink = yes.
Avatar of SteveL13


All 3 are set to Yes.
And there are no labels on the sub-reports.  Only textboxes that are set to Yes.
try removing everything from the subreport, see if thats still not shrinking.
if it works, then place back one by one, see what causes it not to shrink.
Better yet, hide the whole subreport.  In the section it's in, OnFormat event, do:

  Me.<mysubreportcontrolname>.visible = Me!mysubreportcontrolname.Report.HasData

and BTW, note that your always better to set a subcontrol's height to 0 and let it grow rather than try and shrink it if you do use the other method.

Jim, I've tried hiding them but when I try to run the main report it keeps indicating that it can't find each of the sub-reports.  Do I need to somehow identify the parent report in the...  Me!mysubreportcontrolname.Report.HasData  ...part of the entire line of code?

Me.<mysubreportcontrolname>.visible = Me!mysubreportcontrolname.Report.HasData
<<it can't find each of the sub-reports.  >>

  You need to be referring to the sub report control, not the name of the sub report object.

Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Have you tried my suggestion?
bfuchs  -  Yes.  Jim's suggestion seems to be working.