Solved

Make Subreport Display Something When Recordset is Empty

Posted on 2008-10-15
7
486 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Limit number of characters returned to 999 9 31
restore dependent control enabled state on undo 7 29
Runtime Error -2147467259 (80004005) 7 41
Null or "" 28 52
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 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