Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

stop report opening if no data ACCESS 2010

Posted on 2014-09-10
4
Medium Priority
?
828 Views
Last Modified: 2014-09-10
I have the message no data for report in the ON NO DATA event, but the report still opens.  How can I prevent the report opening when there is no data?

Sandra
0
Comment
Question by:ssmith94015
[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
  • 2
4 Comments
 
LVL 25

Expert Comment

by:chaau
ID: 40316060
You need to set the Cancel parameter to TRUE:
Private Sub Report_NoData(Cancel As Integer)
    ' display your custom message box here
    Cancel = True
End Sub

Open in new window

0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 40316110
You will also need to handle the error message your main application will get when the report fails to open.

I cannot remember what the error number is, but I just use a Resume Next after testing for that error.
0
 
LVL 25

Accepted Solution

by:
chaau earned 2000 total points
ID: 40316115
If you open the report via VBA you need to handle this error:
On Error Resume Next
DoCmd.OpenReport "SomeReport", acViewPreview
If Err = 2501 Then Err.Clear

Open in new window

0
 

Author Closing Comment

by:ssmith94015
ID: 40316151
Thanks for the error handling code.  This worked perfectly.

Sandra
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

670 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