Report open... cancel error 2501??

  • Thread starter Thread starter Norman Fritag
  • Start date Start date
N

Norman Fritag

Hi there

I am calling from a form, via button click, to open a report in print
preview.
The report recordsource is a query. The query has in the criteria section a
date field prompt eg : [Enter Staring date].

Now went the user cancel the [enter startdate] prompt, it causes the form
button click event, a runtime error 2501, 'the opening of the report was
cancelled.'

How can I resolve the error? Or what would be a better solution than a
[enter start date] prompt?
I can't have a textfield on the form to enter the date.

kind regards

Norman
 
Norman said:
I am calling from a form, via button click, to open a report in print
preview.
The report recordsource is a query. The query has in the criteria section a
date field prompt eg : [Enter Staring date].

Now went the user cancel the [enter startdate] prompt, it causes the form
button click event, a runtime error 2501, 'the opening of the report was
cancelled.'

How can I resolve the error? Or what would be a better solution than a
[enter start date] prompt?
I can't have a textfield on the form to enter the date.


Use error trapping in the button's Click event procedure to
catch the error.

On Error GoTo ErrHandler
. . .
ExitHere:
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2501
Resume ExitHere
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume ExitHere
End Select Case
End Sub

A text box on the form is the usual way to give users a way
to enter a query parameter. This permits you to use the
OpenReport method's WhereCondition argument instead of using
a query parameter. Without that, you'll need some kind of
pop-up thingy and the one you have is probably as good as
any other.
 
Back
Top