Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to cancel a parameter query cleanly

Status
Not open for further replies.

HarryStamper

Programmer
Jul 24, 2006
15
US
I have a parameter query that is invoked from a form...
If the user clicks cancel from the parameter query...they get an ugly kind of message...is there a cleaner way to exit a parameter query.
 
How about:
Code:
Private Sub cmdQuery_Click()
On Error GoTo Err_cmdQuery_Click

    Dim stDocName As String

    stDocName = "qryQuery"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_cmdQuery_Click:
    Exit Sub

Err_cmdQuery_Click:
    Select Case Err.Number
        Case 2001
            MsgBox "You cancelled " & stDocName
            Resume Exit_cmdQuery_Click
        Case Else
            MsgBox Err.Description
            Resume Exit_cmdQuery_Click
    End Select
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top