PC Review


Reply
Thread Tools Rate Thread

cancel parameter without error?

 
 
BAO
Guest
Posts: n/a
 
      18th Mar 2010
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
 
Reply With Quote
 
 
 
 
Tokyo Alex
Guest
Posts: n/a
 
      19th Mar 2010
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.


"BAO" wrote:

> 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

 
Reply With Quote
 
 
 
 
BAO
Guest
Posts: n/a
 
      19th Mar 2010
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.

"Tokyo Alex" wrote:

> 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.
>
>
> "BAO" wrote:
>
> > 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cancel Macro is user selects 'cancel' at save menu =?Utf-8?B?TWFyaw==?= Microsoft Excel Programming 1 6th Apr 2005 05:45 PM
error STOP:0x0000007B (parameter, parameter, parameter, parameter) robert35 Microsoft Access Getting Started 1 15th Dec 2004 04:28 PM
Cancel Cllick Event Won't Cancel Mike Boozer Microsoft Access Form Coding 4 28th Apr 2004 02:36 AM
cancel system message - opertion cancel liora Microsoft Access Macros 0 7th Sep 2003 10:59 AM
"Find" can't find, "Cancel" can't cancel Jeff Ward Windows XP Internet Explorer 5 3rd Aug 2003 04:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:50 AM.