cancel parameter without error?

B

BAO

I cannot suppress the 2501 error message when cancelling the parameter input.
Please help!
Here is my code:

Private Sub Command88_Click()
On Error GoTo Err_Command88_Click

Dim stDocName As String
stDocName = "rptPrint_F_RecRpt_TransCksSingleCk"

DoCmd.OpenReport stDocName, acViewPreview, , , acWindowNormal

Exit_Command88_Click:
Exit Sub

Err_Command88_Click:
If Err.Number = 2501 Then
'do nothing
Else: MsgBox Err.Description
Resume Exit_Command88_Click
End If

End Sub
 
T

Tokyo Alex

Hi,

What is the recordsouce for the report? Is it a saved query, a SELECT
statement, or is it assigned programatically in the report's Open event?

In the third case, I think you'd need to handle the error in that procedure,
rather than in the launching procedure.

Another possibility is that you have the options in VBA (VBA Editor -> Tools
-> Options... -> General Tab) set to "Break on all errors" in which case
you'll get the error message even if you have error handling set up.

If you had somewhere on your form (a textbox or combobox e.g.) where the
parameter could be entered before launching the report, you could handle null
parameters in advance and likely avoid the problem entirely.

Hope this helps a little,
Alex.
 
B

BAO

You got it. I forgot that I had changed options to break on all errors when
I was working on something else. Thank you so much for the answer.
 

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