Don't want to print a report with no data

M

Maggie

I'm trying to prevent a report from printing whenever
there is no data in the underlying recordset. Not sure
what I'm doing wrong.
When I enter this code:
Cancel = True
MsgBox "There is no data for the key you entered."

into the "OnNoData" event of my report, I get error msg
" The OpenReport action was cancelled"
Run-time error '2501'

back in the calling form at this line of code:
DoCmd.OpenReport "projSearchAdminByArch", acViewPreview, ,
strSQL
 
W

Wayne Morgan

In the calling form, use an error handler and in the error handler tell it
that if the error is 2501 then ignore it.

If Err.Number = 2501 Then Resume Next
 

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

Similar Threads

No data report 2
No Data in Report 2
Cancel report if no data 2
Cancel = True - error 2
Report OnNoData event error 2
Annoying errer message 1
no data on reports 2
Error 2501 4

Top