Cancelling a parameter query

G

Guest

I have a button on a custom switchboard that executes a parameter query. When
the user hits cancel it produces an error msg 2001. The command line for the
button is simply

DoCmd.OpenQuery "RideDistanceParameter", acViewNormal

What coding and where do I put it so that when the user clicks the cancel
button it exits the sub? I am just starting to learn about error handling so
any explinations would be helpful to.
Thank you.
 
R

Rick Brandt

Wylie said:
I have a button on a custom switchboard that executes a parameter
query. When the user hits cancel it produces an error msg 2001. The
command line for the button is simply

DoCmd.OpenQuery "RideDistanceParameter", acViewNormal

What coding and where do I put it so that when the user clicks the
cancel button it exits the sub? I am just starting to learn about
error handling so any explinations would be helpful to.
Thank you.

Are you sure the error is not number 2501? That error is raised any time a
DoCmd.anything is cancelled.

Crude method...

On Error Resume Next
DoCmd.OpenQuery "RideDistanceParameter", acViewNormal

Better Method...

On Error GoTo ErrHandler
DoCmd.OpenQuery "RideDistanceParameter", acViewNormal

Egress:
Exit Sub

ErrHandler:
Select Case Err.Number
Case 2501
'ignore
Case Else
(normal error handling code)
End Select
Resume Egress
End Sub
 

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