Open-Report-Action-Cancelled

J

Junior

Access2K -how can i modify this code to eliminate the
"OpenReport Action was cancelled" when there is no data
and Peport NoData event has Cancel=True


Private Sub cmdovrdue_Click()
On Error GoTo Err_HandleErr_Click

DoCmd.OpenReport "rptCertTrack", acPreview, "", ""

Exit_HandleErr_Click:
Exit Sub

Err_HandleErr_Click:
MsgBox Error$
Resume Exit_HandleErr_Click
 
A

Allen Browne

Tell your error handler to ignore error 2051:

Private Sub cmdovrdue_Click()
On Error GoTo Err_HandleErr_Click

DoCmd.OpenReport "rptCertTrack", acViewPreview

Exit_HandleErr_Click:
Exit Sub

Err_HandleErr_Click:
If Err.Number <> 2501 Then
MsgBox Error$
End If
Resume Exit_HandleErr_Click
End Sub
 
D

Dirk Goldgar

Junior said:
Access2K -how can i modify this code to eliminate the
"OpenReport Action was cancelled" when there is no data
and Peport NoData event has Cancel=True


Private Sub cmdovrdue_Click()
On Error GoTo Err_HandleErr_Click

DoCmd.OpenReport "rptCertTrack", acPreview, "", ""

Exit_HandleErr_Click:
Exit Sub

Err_HandleErr_Click:
MsgBox Error$
Resume Exit_HandleErr_Click

'---- start of revised code ----
Private Sub cmdovrdue_Click()
On Error GoTo Err_HandleErr_Click

DoCmd.OpenReport "rptCertTrack", acPreview, "", ""

Exit_HandleErr_Click:
Exit Sub

Err_HandleErr_Click:
If Err.Number <> 2501 Then
MsgBox Error$
End If
Resume Exit_HandleErr_Click

End Sub
'---- end of revised code ----
 

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