?
Solved

Make Subreport Display Something When Recordset is Empty

Posted on 2008-10-15
7
Medium Priority
?
499 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 2000 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

719 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