The following code will give you what you want. It also queries the user to ensure the user wants to close the app.
The third subroutine can be called when the 'close' on a menu is selected or say a command button.
Note the code in the 2nd sub - it ensures all forms open are closed.
Please ask if any questions.
code
----
Private Sub Form_QueryUnload(Cancel As Integer, UnLoadMode As Integer)
Dim intResponse As Integer
' display a message and verify the user wants to end the application
intResponse = MsgBox("Are you sure you want to exit this application?", _
vbYesNo + vbDefaultButton1 + vbInformation, "Exit"
If intResponse = vbNo Then
Cancel = True
Else
Call Form_Unload(Cancel)
End If
End Sub
------
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
' close all forms that are opened
For i = Forms.Count - 1 To 1 Step -1
Unload Forms(i)
Next
End
End Sub
------
Private Sub mnuFileClose_Click()
Dim Cancel As Integer
Dim UnLoadMode As Integer
' call the procedure 'form_unload' when 'exit' from the
' menu is selected
Call Form_QueryUnload(Cancel, UnLoadMode)
End Sub