When I close Form2, Form1 is still running in the background and the debugging does not stop. I have a button in Form1 that opens Form2 and makes Form1 unvisible.
Is there a simple solution to shut Form1 down whenever I close Form2 and then make the whole program close? (without any button in Form2)
You call Application.Quit
when closing Form2.
If you are using a UserForm:
Private Sub UserForm_Terminate()
Application.Quit
End Sub
If you are using an Access form:
'Close event on Form2
Private Sub Form_Close()
DoCmd.Close acForm, "Form1", acSaveNo
Application.Quit
End Sub
Note that Application.Quit
will really quit the application. If you just want to close the form, use Unload Form1
instead (also, called within one of these blocks of code).