Link to home
Start Free TrialLog in
Avatar of roverturf
roverturfFlag for United States of America

asked on

Make Subreport Display Something When Recordset is Empty

Is there a way to show a subreport's header if the subreport has no data? On a work order report (rptWorkOrder), I have two subreports, one for parts charges (subreportParts) and another for labor charges (subreportLabor). Both subreports are set to can grow=yes and can shrink=no, and both are height=1". If the recordset for subreportParts is empty the subreport is not visible, leaving a 1" in my report.

I would like to put a label under the subreportParts, make it visible if the subreportParts recordset is empty, and set subreportParts.height=lblParts.height on the parent report's on format event - but a label does not have a height property. Any suggestions?
ASKER CERTIFIED SOLUTION
Avatar of jppinto
jppinto
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of roverturf

ASKER

Thanks, jppinto.   I'll try your idea and post my findings back to this thread.

-Richard
Did you've tryed my sugestion?

jppinto
Avatar of Jeffrey Coachman
roverturf,

Why are the subreports  1" tall?

If you set the Can Grow and the Can Shrink properties of the subReport to: YES, the control will grow and shrink based on the number of records it displays.

So, you could really make the subform .1 inches tall and it will display the records just fine.

Look at these screenshots:

JeffCoachman
Skinny-SubReport.JPG
LongSubReport.JPG
Thanks, jppinto.  
Using your suggestion, I built a work order report (portrait, 8.5x11) that had two 1" tall subreports to show parts used.  
Subrpt1 held a recordsource which showed parts used for the work order report (parent).  
Subrpt2 was a copy of subrpt1 with the Detail Section removed and without a recordsource.
On the parent report's Detail SectionOnFormat event I added:

    '/ If the subrpt has no data then show the empty placeholder rpt
    If Me.subrptWoParts.Report.HasData Then
        Me.subrptWoParts.Visible = True
        Me.subrptWoParts_Placeholder.Visible = False
    Else
        Me.subrptWoParts.Visible = False
        Me.subrptWoParts_Placeholder.Visible = True
    End If

So.. if the subrptWoParts had data, the parts used were shown, as expected.  If no parts were used on the workorder the subrptWoParts_Placeholder informed the end user of such.

Thank you for your advice!  I am now using this method on other complex reports as well.    

-Richard

Thank you both for your assistance.

Jeff,  How did you incorporate your example jpg into your answer?

-Richard (roverturf)
I simply attached the jpg image by clicking the "Attach File" button.

Or do you mean: How did I make the image?

JeffCoachman