No data event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I suppress the 'OpenReport action was canceled' message when I set the
cancel = true in the NoData event.
 
You need an error handler in the code that opened the report. The error
number you're looking for is 2501.

Example:
Private Sub cmdMyButton_Click()
On Error GoTo CheckError
DoCmd.OpenReport "rptMyReport, acViewPreview
ExitHere:
Exit Sub
CheckError:
If Err.Number = 2501 Then Resume ExitHere
MsgBox "Error # " & Err.Number & vbCrLf & Err.Description, vbOkOnly +
vbCritical, "Error in cmbMyButton_Click"
End Sub
 
Thank you!!!

Wayne Morgan said:
You need an error handler in the code that opened the report. The error
number you're looking for is 2501.

Example:
Private Sub cmdMyButton_Click()
On Error GoTo CheckError
DoCmd.OpenReport "rptMyReport, acViewPreview
ExitHere:
Exit Sub
CheckError:
If Err.Number = 2501 Then Resume ExitHere
MsgBox "Error # " & Err.Number & vbCrLf & Err.Description, vbOkOnly +
vbCritical, "Error in cmbMyButton_Click"
End Sub
 
Wayne said:
You need an error handler in the code that opened the report. The
error number you're looking for is 2501.

Example:
Private Sub cmdMyButton_Click()
On Error GoTo CheckError
DoCmd.OpenReport "rptMyReport, acViewPreview
ExitHere:
Exit Sub
CheckError:
If Err.Number = 2501 Then Resume ExitHere
MsgBox "Error # " & Err.Number & vbCrLf & Err.Description, vbOkOnly +
vbCritical, "Error in cmbMyButton_Click"
End Sub

What I did a while back was create two custom functions. One for opening
Forms and one for Reports. They take the exact arguments and syntax as
DoCmd.Open... but automatically handle error 2501.

The hardest part is remembering to use them instead of the built in methods.
 

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

Similar Threads

Annoying errer message 1
No Data Problem 2
NoData Event 4
No data event function 2
Open Report Action Cancelled 1
Error 2501 4
Cancel = True - error 2
no data message 1

Back
Top