How do I replace that #error message on a report that results from no data
found in the underlying query. I would like to return either zeroes or "no
data"
Code the report's OnNoData event:
MsgBox "There is no data to report on"
Cancel = True
You'll get a message and the report will not run.
If the report was opened from a command button on a form (a
switchboard for instance), this will result in an error. Trap the
error in the command button event that opened the report:
On Error GoTo Err_Handler
DoCmd.OpenReport "ReportName"
Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.number & " " & Err.Description
End If
Resume Exit_This_Sub