Solved

Display label when subreport empty

Posted on 2009-07-15
2
275 Views
Last Modified: 2013-11-28
I have a report that contains a subreport.  When the subreport does not have any data to display I would like a label to appear with a message saying "No New Clients".  I have the label on the subreport with the visible property set to false.  I also have the below code.  This works when I run the subreport separately, but when I run it with the main report it does not work.  Any suggestions?
Private Sub Report_NoData(Cancel As Integer)
    Me.lblNNC.Visible = True
End Sub

Open in new window

0
Comment
Question by:nfstrong
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 24860678
Add  a label to the report behind the the subreport which has the caption of
"No Data To Report"

In the Format event procedure for the section that contains the subreport, do..

if Me.rptsub.Report.HasData = true then
    Me.rptsub.visible =  True
    Me. lblNoData.visible = False
else
   Me.rptsub.visible =  False
   Me. lblNoData.visible = True
end if

Use your own names for the label and the subreport, of course, instead of rptsub and lblnodata.
0
 
LVL 39

Expert Comment

by:thenelson
ID: 24860695
Put the label on the main report behind the subreport and use this code:
Private Sub Report_NoData(Cancel As Integer)
    Me.Parent.lblNNC.Visible = True
    Me.Visible = False
End Sub
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

816 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

12 Experts available now in Live!

Get 1:1 Help Now