Do not print report if no results from query???

  • Thread starter Thread starter tcek
  • Start date Start date
T

tcek

we run reports every day. the data is based on real time data and some of the
queries that the reports originate from do not have any results. In an effort
to save paper, I would only like to print a report if there are values in the
report. I want to avoid printing a blank report. any ideas would be welcome.
thanks in advance.
 
In the report's "On No Data" event put something like the following code:

msgbox "The report you are trying to print has no data. Try again later"
cancel=true

hope that helps
 
Reports have a property called On No Data. Set this to [Event procedure]
click on the elipses button and simply put in the code
Cancel = True
 
Cancel the report's NoData event.
Access fires this event if the report's source generates no records.

If you open the report programatically, Access uses error 2501 to notify you
that the report did not open. Use error handling to ignore this error.
Alternatively, use a wrapper function to open the report, and have it handle
the error, like this:
http://allenbrowne.com/AppPrintMgtCode.html#OpenTheReport
 
Back
Top