Solved

Display label when subreport empty

Posted on 2009-07-15
2
273 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
Comment Utility
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
Comment Utility
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

762 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

9 Experts available now in Live!

Get 1:1 Help Now