Okee-Dokee :
I am experimenting with different ways to stop a report from Previewing if there is NoData. I tried the NoData event for the report and added my MsgBox “No Data” and Cancel = True. This works fine if I access the report directly BUT when I access the report through the OnClick Event of a button in a form it displays my MsgBox AND the system generated one about Canceling an event, etc, etc. No matter what I do, I cannot stop that from showing.
Next, I tried adding DCount to the OnClick Event of the button so I could stop it even before I got to the report (see Code below). This works fine, but I have noticed that it does increase the wait time for the user by a few seconds or so.
I guess my questions would be : Any ideas why I cannot stop the system generated message when I go through a form to view a report. Or, any other ideas at the OnClick Event of the Preview button that may be a bit quicker than DCount ????
Any suggestions would be warmly welcomed. TIA
Private Sub cmdPreview_Click()
On Error GoTo Err_cmdPreview_Click
DoCmd.Hourglass True
*Checks to see if there is any data matching the criteria *
If DCount(“*”, “qryReport02_ProjectActivityLog”) < 1 Then
DoCmd.Hourglass False
MsgBox "No matches found. @Please try again.@"
Exit Sub
End If
* Closes Report Selection Form *
DoCmd.Close
* Opens Report *
DoCmd.OpenReport "rptProject-Activity-Log", acPreview
DoCmd.Hourglass False
Exit_cmdPreview_Click:
Exit Sub
Err_cmdPreview_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdPreview_Click
End Sub