Cancelling a parameter query

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
Back
Top