Exiting a report when there's no data

RichS

Healthy software!
Local time
Today, 17:17
Joined
Apr 16, 2008
Messages
44
I'm hoping this is something simple to fix...

I've got a database written in Access 2010 that shows many reports. When the report is selected and data is available, it is shown as a full screen preview with the print dialog box displayed over it. However, I am having a problem in that when there is no data, a message box is displayed that's invoked from the 'on no data' setting but when it's dismissed the report is still displaying. How do I prevent this from happening?
 
You have two options to look into:

1. On No Data event of the report
2. Perform a DCount() on the reports Record Source before opening it and act accordingly.
 
I'm using the 'On no data' event of the report to show the message box, but not sure what it is I should follow it with.
 
There are arguments in the event you can use. Have you actually looked into it?
 
That's a bit sarcastic... Yes, I have looked into it but could not find any help or advice, which is why I posted here!
 
Last edited:
Set the Cancel = True
Code:
Private Sub Report_NoData(Cancel As Integer)
  MsgBox ("No data")
  Cancel = True
End Sub
 
Not to worry... Another forum was able to help me by providing the vba code I needed and all is working fine now.

Edit: Thanks for that last post. It came in just as I was typing this!
 
That's a bit sarcastic... Yes, I have looked into it but could not find any help or advice, which is why I posted here!
It wasn't meant to be sarcastic. On searching with the terms "on no data access report" I was able to get this link and even the first link has code for this.
 

Users who are viewing this thread

Back
Top Bottom