Userform exit

ShoYnn

Board Regular
Joined
Mar 20, 2019
Messages
60
Office Version
  1. 2016
Platform
  1. Windows
I have a simple userform that is used to either change the dates of a scheduled job or delete it. For the text boxes the user would enter the new dates, I have a private sub that runs when the text box is exited to verify it is a date. Everything works perfectly, except if the focus is on a text box, if the user closes the form via the X button it still pops up the message from the text box exit private sub. How would I be able to allow the user to close the userform without fear of the message box popping up? Thanks!

Also, this is on a government computer, so I can't upload stuff the fancy ways, if needed I will have to take pictures of it.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about this- placed in the userform module... You will need another CommandButton for the user to close the form with

VBA Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

    If CloseMode = vbFormControlMenu Then
        Cancel = True
        MsgBox "Please use the ""EXIT"" button to close the form", vbOKOnly, "VIZCAYA"
    End If
    
End Sub
 
Upvote 0
How about this- placed in the userform module... You will need another CommandButton for the user to close the form with

VBA Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

    If CloseMode = vbFormControlMenu Then
        Cancel = True
        MsgBox "Please use the ""EXIT"" button to close the form", vbOKOnly, "VIZCAYA"
    End If
   
End Sub
I was kind of thinking of forcing a close/cancel button, but I was also curious if there was a way without that. I'll give this a try when I get back to work tomorrow and let you know how it goes!
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,753
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top