Error Message box

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hi, I have two problems for Preview Button and Print Button.

1) Preview Button: When I select and preview and got no report and click
"Ok". I got the message saying "The openreport action was canceled". Is
there a way to avoid that message.

2) Print Button: When I select a report and got the message "No report"
and click "OK" but it trying to print something while showing Print is
running from Page 1 to 3. That is it. I don't want to show the print
dialog message if there is no report.

Here is the code if I miss anything based on #1 and #2.
**********************************************
Private Sub Report_NoData(Cancel As Integer)
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
strMsg = "There are no records for the report"
intStyle = vbOKOnly
strTitle = "No Data for Date Range"
MsgBox strMsg, intStyle, strTitle
Cancel = True
End Sub
**********************************************

Your help would be much appreciated.
 
Bill,

Ther error is not coming from the NoData event on the report. It's comming
from the OpenReport method that the NoData event cancels. If you add error
handling to the procedure that opens the report, this message will go away.
Try this:

Private Sub PrintButton_Click()
On Error Resume Next 'This line will stop the message
DoCmd.OpenReport...etc
End Sub

HTH,
Josh
 
Back
Top