Error if I launch a Parameter Report from a Text box and cancel it

J

Joe

I have with a lot of help from this board been able to launch a report from a
text box. If I launch the report and at the "Enter Date" prompt I decide to
cancel it this causes an error. Is there somthing I place in the "Event
Procedure" to stop this. You can just click "End" and everything is good but
I would not want anyone to hit debug instead.
 
D

Douglas J. Steele

I haven't actually tested, but I suspect you're getting an error 2501 about
canceling the previous command.

In the routine where you're launching the report, you need to put error
handling that checks for that particular error number and ignores it if it
occurs.

If you're not familiar with writing your own error handlers, Allen Browne
has a good introduction at http://www.allenbrowne.com/ser-23a.html
 
J

Joe

You are correct it is error 2501. Sorry for not giving you that information.
It would seem I would just want to exit the routine. Would the error routine
be in the Privite Sub or before it?
 
J

Joe

I think I got it just added:
Private Sub..................
On Error GoTo abort
DoCmd Open Report........................
Abort:
End Sub


Thanks for you help.
 
D

Douglas J. Steele

You really should use property error handling.

Private Sub..................
On Error GoTo abort
DoCmd Open Report........................

EndIt:
Exit Sub

Abort:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & ": " & Err.Description
Resume EndIt
End Select

End Sub
 
J

Joe

Thank You for the example of the correct way.

Douglas J. Steele said:
You really should use property error handling.

Private Sub..................
On Error GoTo abort
DoCmd Open Report........................

EndIt:
Exit Sub

Abort:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Number & ": " & Err.Description
Resume EndIt
End Select

End Sub
 
D

Douglas J. Steele

I know. It's very frustrating. I never make mistakes, just the computer
does!
 

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