don't print reports with no records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form designed so that the user clicks a button and it prints a
report without displaying it (acNormal). However if there is no records the
report prints a page with out any stored information on it. How can I make it
so that it will not do this?

I want to send the user a message letting them that there is not any pages
to print so I tried sending them this message box and then the command
docmd.close under the on no data property, but it gives me the error message:
2585 "This action can't be carried out while processing a form or report
event" I can do just the close command but not both. If I switch the order
around then it just closes and doesn't display the message.
 
Dan,

Reports have a NoData event.

Private Sub Report_NoData(Cancel As Integer)
Cancel = True
End Sub

But you may get an error in the code that calls the report, so add a little
something just before calling the report:
On Error Resume Next
DoCmd.OpenReport .........

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Back
Top