Query Parameters and Forms

  • Thread starter Thread starter KC
  • Start date Start date
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?
 
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
 
Back
Top