Solved

Make Subreport Display Something When Recordset is Empty

Posted on 2008-10-15
7
480 Views
Last Modified: 2013-11-28
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?
0
Comment
Question by:roverturf
  • 3
  • 2
  • 2
7 Comments
 
LVL 33

Accepted Solution

by:
jppinto earned 500 total points
ID: 22726465
Make a subreport like rptNoData that is only a Lable with text like "No records" and place it above the subreportParts.. Make this report Visible propertie to No.

On the main report, On No Data event, put this code:

Private Sub Report_NoData(Cancel As Integer)
    Report!rptNoData .Visible = True
End Sub

jppinto
0
 

Author Comment

by:roverturf
ID: 22740941
Thanks, jppinto.   I'll try your idea and post my findings back to this thread.

-Richard
0
 
LVL 33

Expert Comment

by:jppinto
ID: 22743724
Did you've tryed my sugestion?

jppinto
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22744647
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
0
 

Author Closing Comment

by:roverturf
ID: 31509045
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

0
 

Author Comment

by:roverturf
ID: 22782841
Thank you both for your assistance.

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

-Richard (roverturf)
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22793808
I simply attached the jpg image by clicking the "Attach File" button.

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

JeffCoachman
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now