Query Parameters and Forms

K

KC

I have a set of queries that use parameters to sort data
(about 30). They work great in both the query view and
when run from forms. However when the cancel button or
close (x) button are used they work just fine in the query
view, when the exact same query is run from a button on a
form and the cancel or x button are used I get an action
failed error. Does anyone know how to fix this so that
the error message stops popping up?
 
F

Fredg

You need to trap the error in the Button's click event.

On Error GoTo Err_Handler

DoCmd.OpenQuery "Query Name"

Exit_This_Sub:
Exit Sub

Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error # " & Err.Number & " " & Err.Description
End If
Resume Exit_This_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