Must close or hide topmost modal form first (Error 402)

The modal form you are trying to close or hide isn't on top of the z-order. This error has the following cause and solution:

  • Another modal form is higher in the z-order than the modal form you tried to close or hide. First use either the Unload statement or the Hide method on any modal form higher in the z-order. A modal form is a form displayed by the Show method, with the style argument set to 1 - vbModal.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.