Form not executing the unload event

Can anyone think of a reason why when I click the X in the upper right hand corner of my form the unload event doesn't get executed?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
Only reason I can think of could be if the QueryUnload event was firing and was coded to cancel the unload.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BofADevAuthor Commented:
The problem was I was clicking the x on the mdi parent form instead of the child where I was trying to see the unload event.  Still though I would have thought it would have fired each mdi child form's unload event...oh well :)

So what is the difference between QueryUnload and Unload?  Which fires first?
jkaiosIT DirectorCommented:
To find out the "order" of which event gets fired first:

1) Create a new project with a new form

2) Put codes in the following form events to print the event name to the Immediate Window
      Private Sub Form_Deactivate()
         Debug.Print "Deactivate"
      End Sub
      Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
         Debug.Print "QueryUnload"
      End Sub
      Private Sub Form_Terminate()
         Debug.Print "Terminate"
      End Sub
      Private Sub Form_Unload(Cancel As Integer)
         Debug.Print "Unload"
      End Sub

3) Run your project

4) End the project

5) Now bring up the Immediate Window to see which event got fired first
You can use the form_unload() event and write your code to unload the form in this event
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.