PDA

View Full Version : UserForm_QueryClose vs Unload Me



av8tordude
08-31-2011, 07:32 AM
In the Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer), is there a way to distinquish between clicking the "X" button on the userform vs unloading the form via a command button?

Kenneth Hobs
08-31-2011, 10:07 AM
Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
MsgBox "Use a button to close this userform."
Cancel = True
End If
End Sub