Close X button on Usser Form

  • Thread starter Scardona Bay Viktor
  • Start date
S

Scardona Bay Viktor

Hi Gentleman.

I have a form that has the blue title bar along with the "X" in the upper
right corner.

I am having trouble finding the code or process of eliminating the "X" so
the user will have only once choice to close the form through the Close
button created in the form.

Any suggestions would be highly appriciated to get be through this hurdle.

Thanks!
 
J

Jon Peltier

Here's a better way. The user wants to close the form, so let them close the
form using either the close button or the big X in the corner. When they
click the X, you simply want to cancel the normal behavior of the X and run
the close button code.

Put this procedure into your userform code module:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
' how was the form closed? vbFormControlMenu = X in corner of title bar
If CloseMode = vbFormControlMenu Then
' cancel normal X button behavior
Cancel = True
' run code for click of Close/Cancel button
btnCancel_Click
End If
End Sub

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top