Not that I know of via a query, (although someone else may be able to clarify that). But if you do it via a report, there's an option for OnNoData on the Event tab of the report.
In the code here, put
Private Sub Report_NoData(Cancel As Integer)
msgbox "No data to view", vbOKOnly, "No Records"...