Search code examples
ms-accessvbarefreshms-access-2016

Handling Error 2001 on Cancel - MS Access 2016


I have a form that I am requerying on the click of a button using

DoCmd.Requery

This works and I am able to requery the form based on the criteria I specified in my query table. However, if I cancel the requery, rather than click OK, I get an error (2001). How can I have the form remain as is if the user cancels?

Thanks!


Solution

  • Does the following work?

      On Error Resume Next
      DoCmd.Requery
      On Error GoTo 0