Need help with "The OpenReport action was cancelled" error message

RDSJMS

Registered User.
Local time
Today, 15:57
Joined
Jan 25, 2006
Messages
30
I need to trap an error if the user enters a item number that does not exist in the table.

I created a macro for the OnNoData event and it works great when I test the macro by running the report from the Reports Objects list.

However, when I run the report from a command button on my Switchboard, after my custom error message appears warning that an invalid item number was entered and the I click OK, I receive the error "The OpenReport action was canceled."

Obviously, I'm missing something in the command button properties, but I haven't got a clue. My error code is as follows:

Private Sub PrintOneSpec_Click()
On Error GoTo Err_PrintOneSpec_Click

Dim stDocName As String

stDocName = "rpt_Print 1 Packaging Spec with Revision History"
DoCmd.OpenReport stDocName, acPreview

Exit_PrintOneSpec_Click:
Exit Sub

Err_PrintOneSpec_Click:
MsgBox Err.Description
Resume Exit_PrintOneSpec_Click

End Sub


I want the user to be returned to the Switchboard if there are no records found.

Any and all help will be appreciated.
 
Last edited:
Err_PrintOneSpec_Click:
If Err <> 2501 Then
MsgBox Err.Description
End If
Resume Exit_.................
End Sub
 
Mstef,

Perfect...thank you.

Randy
 

Users who are viewing this thread

Back
Top Bottom