The only way to stop code executing is to use the acDialog in the OpenForm command. Set the Form's Modal and Popup to Yes does not do this. So, when you need code execution to stop ... you need acDialog.
There is a 'trick' to set the Modal and Popup to Yes ...and then open the Form normally, but ... no need in this case.
mx