[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

No Data property

Posted on 2012-09-17
5
Medium Priority
?
393 Views
Last Modified: 2012-09-17
I have a Cancel event in a reports No Data property. How do you allow report to be opened if there is data in the same report's sub report
0
Comment
Question by:DatabaseDek
  • 2
  • 2
5 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38406560
try this logic,
in the Nodata event of your report check if there is data in your subreport ,

if there is data set Cancel=false,
    else, set cancel=true
0
 

Author Comment

by:DatabaseDek
ID: 38406583
I have tried this in a thousand variations.

If Me!MySubReortName.Report.HasData = 0 Then

as explained in the help file. It doesn't work
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38407204
I've tried that in a few variations.

This seems to work in the Subreport's Open Event:


Private Sub Report_Open(Cancel As Integer)
    If Me.HasData = False Then
        MsgBox "No Data!"
        DoCmd.Close acReport, Me.Parent.Name
    End If
End Sub

Open in new window



You'll have to add error handling in whatever code opens this report, as cancelling/closing a report while it is opening will raise error 2501.

Your error handling can be as simple as:

On Error Resume Next
Docmd.OpenReport "YourReportName", acViewPreview

Open in new window

0
 

Author Closing Comment

by:DatabaseDek
ID: 38407926
Great thank you!!

Derek
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38407930
:)

Glad to help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

830 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