I'm having problems capturing when a form has focus and when it loses focus. I have an app that has several different forms. when the user is finished with one form I need to close it. I thought I could do this with the lostfocus event however I am not able to get the form to respond to it.

Could someone please explain when a form has focus.

Example code

Private Sub form1_GotFucus()