Report errors

C

Cameron

How do I not show a report if it doesn't contain data? I also do not want the
report poping up a box requesting my input to close the routine. Would be
nice just to show a message saying there was no data and then required an
acknowledgment.
 
F

fredg

How do I not show a report if it doesn't contain data? I also do not want the
report poping up a box requesting my input to close the routine. Would be
nice just to show a message saying there was no data and then required an
acknowledgment.

Code the report's OnNoData event:

MsgBox "No records to report on."
Cancel = True

Note: This will throw error 2501 if the report was opened from a VBA
event.
In that case add error handling to that event to trap error 2501:

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