Try using this code and see if it works for your situation.

Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)


    Select Case UnloadMode
        Case vbFormControlMenu
            MsgBox "The user chose the Close command from the Control menu on the form."
        Case vbFormCode
            MsgBox "The Unload statement is invoked from code."
        Case vbAppWindows
            MsgBox "The current Microsoft Windows operating environment session is ending."
        Case vbAppTaskManager
            MsgBox "The Microsoft Windows Task Manager is closing the application."
        Case vbFormMDIForm
            MsgBox "An MDI child form is closing because the MDI form is closing."
        Case vbFormOwner
            MsgBox "A form is closing because its owner is closing."
    End Select


End Sub
The vbControlMenu is what was passed to the QueryUnload event when I clicked the "X" in the upper right hand corner and when I went to the control menu clicked close.

If you have an exit on your menu bar or a command button the vbFormCode will be passed in.


Is this what your looking for?