View Full Version : Parameter query????


rupes_mahal
10-19-2001, 02:35 PM
Hi..

I have a parameter query which brings up a dialog box prompting the user to insert a number (relating to the number of years the user wants to see data about).

The dialog box has a OK and Cancel button on it. The OK button works fine. But the Cancel button does not...it returns an error:

Run-Time error "2001"

You canceled the previous operation

This is the error message which appears.

The query has been added to a button.
the code for that button is:

Private Sub datasheetview_Click()
DoCmd.OpenQuery "DatePartQuery"
End Sub

I don't know what is wrong.....please help...

thankyou in advance

ruby

Jack Cowley
10-19-2001, 04:36 PM
Nothing is wrong. Access is just letting you know that you cancelled the operation. If you want to eliminate the message then change your code to look like this:

Private Sub datasheetview_Click()

On Error GoTo ErrorHandler

DoCmd.OpenQuery "DatePartQuery"

ErrorHandlerExit:
Exit Sub

ErrorHandler:
If Err.Number = 2001 then Exit Sub
Msgbox Err.Number & " " & Err.Description
Resume ErrorHandlerExit

End Sub

[This message has been edited by Jack Cowley (edited 10-19-2001).]

rupes_mahal
10-20-2001, 04:29 AM
Thanks Jack.....it worked.