?
how do i do this?
if the user clicks the big 'X' in the upper right corner, i want to ask if they want to close.
if yes unload me
else
'what here?
end if
i have no clue so any suggestions would be super cool.
thanks
Printable View
?
how do i do this?
if the user clicks the big 'X' in the upper right corner, i want to ask if they want to close.
if yes unload me
else
'what here?
end if
i have no clue so any suggestions would be super cool.
thanks
I THINK THIS SHOULD WORK..
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
prompt$ = "ARE YOU SURE YOU WANT TO EXIT?"
reply = MsgBox(prompt$, vbYesNo, "EXIT")
If reply = vbYes Then
Unload Me
Else
Cancel = True
End If
End Sub
Code:Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = 1 Then
X = MsgBox("Are you sure you want to exit?", vbYesNo)
If X = vbYes Then
' Unload Code Here
Else
Cancel = 1
End if
Else
' OS Is forcing close, put forced exit code here
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("Do really want to quit?", vbQuestion Or vbYesNo, "Quit?") = vbNo Then
Cancel = 1
End If
End Sub
Query Unload event details:
Code:Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Select Case UnloadMode
Case vbFormControlMenu ' =0 closed by user
Case vbFormCode ' =1 form closed by code
Case vbAppWindows ' =2 windows is ending
Case vbAppTaskManager ' =3 task manager is closing
Case vbFormMDIForm ' =4 mdi parent is closing
Case vbFormOwner ' =5 the owner form is closing
End Select
End Sub
thanks all!!!
What do I have to do for making the "No" or "cancel" button as the default button ?:(
X = Msgbox("Are you sure you want to exit?", vbyesnocancel or vbdefaultbutton2) ' No is default
X = Msgbox("Are you sure you want to exit?", vbyesnocancel or vbdefaultbutton3) ' Cancel is default
Thanks !! :)