Open-Report-Action-Cancelled

  • Thread starter Thread starter Junior
  • Start date Start date
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
 
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
 
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 ----
 
Back
Top