Solved

Display label when subreport empty

Posted on 2009-07-15
2
274 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unrecognized Database Format 8 93
Create Form using Wizard 14 36
how to link subforms ms/access VBA 6 30
error 3022 in access vba 3 14
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
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.

867 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

22 Experts available now in Live!

Get 1:1 Help Now