Printing reports with no data

  • Thread starter bhrosey via AccessMonster.com
  • Start date
B

bhrosey via AccessMonster.com

Actually the title of this question is a little misleading, sorry. This
should be fairly simple. I run 5 different reports for 2 different shifts
based on certain product catagories that were produced the previous day.
Sometimes there is data for those reports and sometimes not. Instead of the
report opening in preview, I would rather just have a MsgBox pop up that says
there's nothing to report. Other than date and shift information, I'm
pulling up the product SKU, description of the product, start and end time,
qty and so on. please help! Thanks

Bill R.
 
J

John Spencer

USe the reports NoData event and set Cancel = True in the NoData Event.

Private Sub Report_NoData(Cancel As Integer)
Cancel = True
MsgBox "No data for this report"
End Sub


If you are calling the report from a button on a form or through code, you
need to trap error 2501 in the CALLING code or you will get a message that
the report was cancelled in addition to the message box.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
J

jmonty

Open the report in design mode.
Click View> Code.
Enter the following:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "No Data Was found for report: " & Me.Name
End Sub
 
B

bhrosey via AccessMonster.com

Thank you both, they both worked. John, how do I trap that error that you
mentioned? I still fairly new to writing code. thanks
Open the report in design mode.
Click View> Code.
Enter the following:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "No Data Was found for report: " & Me.Name
End Sub
Actually the title of this question is a little misleading, sorry. This
should be fairly simple. I run 5 different reports for 2 different shifts
[quoted text clipped - 6 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top