QueriesDialog Box

V

veronicamars

I created a Queries Dialogbox to open all the queries in my database using
the DblClick feature, which it does....however when i open the query where
you have to enter a field value and you have the option of pressing ok or
cancel it wont work when i press the cancel button...it says theres a problem
with the on click command can someone help me please...thanks
 
R

Rick Brandt

veronicamars said:
I created a Queries Dialogbox to open all the queries in my database using
the DblClick feature, which it does....however when i open the query where
you have to enter a field value and you have the option of pressing ok or
cancel it wont work when i press the cancel button...it says theres a problem
with the on click command can someone help me please...thanks

Whenever you cancel anything done with the DoCmd object that is considered an
error. I assume you are using...

DoCmd.OpenQuery

Your code just needs an error handler that is set up to ignore error number
2501.

On Error GoTo ErrHandler

DoCmd.OpenQuery "QueryName"

Egress:
Exit sub

ErrHandler:
Select Case Err.Number
Case 2501
'ignore
Case Else
MsgBox Err.Description
End Select
Resume Egress
End Sub
 
V

veronicamars

Thanks but I just tried it and it didn't work...I am using the private
function DisplayQuery..and when i hit cancel in the parameter value box it
says "The expression on Dbl CLick you entered as the event property setting
produced the following error: You canceled the previous operation"
 
R

Rick Brandt

veronicamars said:
Thanks but I just tried it and it didn't work...I am using the private
function DisplayQuery..and when i hit cancel in the parameter value box it
says "The expression on Dbl CLick you entered as the event property setting
produced the following error: You canceled the previous operation"

Did you put the error handler inside you function (DisplayQuery)?

Post your code.
 
V

veronicamars

yes but i had to change the "sub" to "function" because it said that i can't
incorporate sub into a function but even changing that the error still
appears when i press cancel in the parameter function window
 
R

Rick Brandt

veronicamars said:
yes but i had to change the "sub" to "function" because it said that i can't
incorporate sub into a function but even changing that the error still
appears when i press cancel in the parameter function window

My mistake. Apparently for canceling a parameter query the error number to
ignore is 2001, not 2501.
 

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