roverturf
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=lblP arts.heigh t on the parent report's on format event - but a label does not have a height property. Any suggestions?
I would like to put a label under the subreportParts, make it visible if the subreportParts recordset is empty, and set subreportParts.height=lblP
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did you've tryed my sugestion?
jppinto
jppinto
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
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
ASKER
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.Ha sData Then
Me.subrptWoParts.Visible = True
Me.subrptWoParts_Placehold er.Visible = False
Else
Me.subrptWoParts.Visible = False
Me.subrptWoParts_Placehold er.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
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.Ha
Me.subrptWoParts.Visible = True
Me.subrptWoParts_Placehold
Else
Me.subrptWoParts.Visible = False
Me.subrptWoParts_Placehold
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
ASKER
Thank you both for your assistance.
Jeff, How did you incorporate your example jpg into your answer?
-Richard (roverturf)
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
Or do you mean: How did I make the image?
JeffCoachman
ASKER
-Richard