Error Dialog Box: OpenReport Action Cancelled (1 Viewer)

jalge

Registered User.
Local time
Today, 07:37
Joined
Apr 14, 2003
Messages
24
I am using a command button to open a form that gathers data for a report. I have added an OK button and a Cancel button to the pop up form using the built in IsLoaded function in combo with the Close method in a macro that controlls the button.

Whenever I press the Cancel Button to close the pop up form, I get a Dialog Box that says "The OpenReport Action was cancelled." The dialog box has only one option, pressing Ok.

How do I supress this dialog box from showing up?
 

Elana

Registered User.
Local time
Today, 04:37
Joined
Apr 19, 2000
Messages
232
This is error #2501. In my print procedure, I add error handling code like this:



Private Sub cmdPrintIt_Click()
On Error GoTo PrintIt_Err

' enter your code

PrintIt_Exit:
Exit Sub

PrintIt_Err:
Select Case Err.Number
Case 2501
Resume PrintIt_Exit
Case Else
MsgBox "Error Number: " & Err.Number & "Description: " & Err.Description
Resume PrintIt_Exit
End Select

End Sub

HTH
 

jalge

Registered User.
Local time
Today, 07:37
Joined
Apr 14, 2003
Messages
24
I'm kind of new to this, so please excuse my apparent lack of sophistication...

The error does not come into play when printing. It only happens when you open the pop up form (using my user defined command button that opens the form), then press my user defined "Cancel" button.

Would the code be added to one of the command buttons?

My issue with getting the dialog box is that it is unnecessary. By clicking cancel, I know that the OpenReport action has been cancelled. I don't need Access to tell me about it again.

Is there a universal way to supress such messages?
 

jalge

Registered User.
Local time
Today, 07:37
Joined
Apr 14, 2003
Messages
24
Ok, it looks like this topic has come up many times before. I used the search engine and found several previous similar questions and responses. I'll try those out.

By the way, the search engine in this forum works really well. I have been on other forums where the search engines are horrible, so have been leary of using them.

:D
 

jalge

Registered User.
Local time
Today, 07:37
Joined
Apr 14, 2003
Messages
24
Ok, I found an answer in an error-trapping post, and it works well. For others for future reference, here is what I did:

I added the following code to the command button that opens the pop up form:

Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

Dim stDocName As String

stDocName = "rptCountyBilling"
DoCmd.OpenReport stDocName, acPreview

Exit_Command13_Click:
Exit Sub

Err_Command13_Click:
If Err = 2501 Then
Exit Sub
Else
MsgBox Err.Description
Resume Exit_Command13_Click
End If

End Sub
 

Elana

Registered User.
Local time
Today, 04:37
Joined
Apr 19, 2000
Messages
232
Looks almost exactly like the code I gave you :confused:
 

jalge

Registered User.
Local time
Today, 07:37
Joined
Apr 14, 2003
Messages
24
Sure does. I just used If..Then rather than Case..Else.

I'm not much of a code writer, and don't use Case..Else much. It took seeing the parallel in the IF..Then for me to figure it out.

Thanks for your help.
 

Users who are viewing this thread

Top Bottom