You'd be better off if you did the following in your form's QueryUnload event. You may not need to check for all the conditions, but you probably should at least consider if you still want to ask the user if he/she wants to exit if it's Windows or your code that is closing the form.
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim retVal As Integer
Select Case UnloadMode
Case vbFormControlMenu
' The user chose the Close command from the Control menu on the form
retVal = MsgBox("Are you sure you want to exit?", vbYesNo, "Exit")
If retVal = vbYes Then
Cancel = True
End If
Case vbFormCode
' The Unload statement is invoked from code.
Case vbAppWindows
' The current Microsoft Windows operating environment session
' is ending.
Case vbAppTaskManager
' The Microsoft Windows Task Manager is closing the application.
Case vbFormMDIForm
' An MDI child form is closing because the MDI form is closing.
vbFormOwner
' A form is closing because its owner is closing.
End Select
End Sub