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 Button on Parameter Query Nancy Microsoft Access Queries 1 12th Jun 2008 08:14 PM
Error if I launch a Parameter Report from a Text box and cancel it Joe Microsoft Access Getting Started 8 15th Jan 2008 12:57 PM
parameter box cancel button =?Utf-8?B?QW5u?= Microsoft Access Queries 2 17th Jun 2005 05:53 PM
Cancel parameter query Ashley Microsoft Access Queries 0 26th Jul 2004 10:52 PM
Parameter Query Error on Cancel zSplash Microsoft Access Getting Started 0 6th Oct 2003 05:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:44 AM.