No Data To Print

  • Thread starter luis_a_roman via AccessMonster.com
  • Start date
L

luis_a_roman via AccessMonster.com

I have a report that If there is not data to print, I would like to display a
message indicating that there are no record to print. I'm able to use the
nodata event to display the message but I still open the blank report in
preview mode. I included a Docmd command to quit the report but it does not
work.

My question is; is there anyway that I can display the message and avoid the
blank preview reprot from showing?

Your guidance and knowledge share will be appreciated.

Luis
 
J

John Spencer

Normally, all you need to do is set Cancel = True in the On No Data event.

If you are calling the report from somve VBA code you will have to trap the
error that is generated.

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

fredg

I have a report that If there is not data to print, I would like to display a
message indicating that there are no record to print. I'm able to use the
nodata event to display the message but I still open the blank report in
preview mode. I included a Docmd command to quit the report but it does not
work.

My question is; is there anyway that I can display the message and avoid the
blank preview reprot from showing?

Your guidance and knowledge share will be appreciated.

Luis

In the Report's NoDataEvent, write:

MsgBox "There are no records."
Cancel = True

If you have used code to open the report, this will raise Error 2501
"You have canceled ....etc."
Trap this error in the code event you have used to open the report.

On Error GoTo Err_Handler
DoCmd.OpenReport "ReportName", acViewPreview

Exit_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_Sub
 

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