-
Is there a way to stop a form from unloading? I saw some code here and mimic'd it, however it isn't working so either I have something wrong or you can't do it ?
Assume CloseDown is just a clean up sub.
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim r
If UnloadMode = 0 Then
r = MsgBox("Are you sure you want to close PostIT? (You will not receive messages until you run it again)", vbYesNo)
If r = vbNo Then
Cancel = False
Else
CloseDown
End If
End If
End SubSub
-
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("Are you sure you want to exit", vbYesNo + vbQuestion, "Exit") = vbNo Then
Cancel = True
End If
End Sub
Change Cancel = False to Cancel = True (in your code of course :))