Solved

stop report opening if no data ACCESS 2010

Posted on 2014-09-10
4
772 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 47

Expert Comment

by:Dale Fye (Access MVP)
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 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

732 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