Cancel an exit
As a user, I like to click on the X button to close any dialog.
If you have special code built into your "Cancel" button, why not just call that
same code.
Option Explicit
Private Sub CommandButton1_Click()
MsgBox "Ok was clicked"
End Sub
Private Sub CommandButton2_Click()
MsgBox "Cancel was clicked"
Unload Me
End Sub
Private Sub UserForm_Initialize()
With Me.CommandButton1
.Caption = "Ok"
.Default = True
End With
With Me.CommandButton2
.Caption = "Cancel"
.Cancel = True
End With
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Call CommandButton2_Click
End If
End Sub
ranswrt wrote:
How do I give an option to stop an exit from a userform when the 'X' is used
on them form?
Thanks
--
Dave Peterson
|