I have a form in which all events call macros. I am converting all of my macros to code since I need to create a runtime version of the app.
I have a double-click events of a Last Name control (and several others). On the On DblClick event, the macro Applies a Filter using ApplyFilter in which a query is opened prompting for a last name to search. After I click OK, the record(s) matching the criteria entered displays via my form. If I click Cancel instead of OK when prompted for the Last Name to Search, the parameter box just disappears. This works great with a macro. When converting this macro to code, I use DoCmd.ApplyFilter "qrySearchForName" When I run this code and enter a last name to search when prompted and click OK, the record(s) matching my criteria are displayed. The problem occurs when I click 'Cancel' at the parameter box. I receive a runtime error '2501' indicating the ApplyFilter command was canceled. How can I avoid getting this error? All I want to do is cancel the filtering. I would rather not include "On Error Resume Next" in my code.