Error Message box

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.
 
J

Joshua A. Booker

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
 

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