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
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -
http://PeltierTech.com
_______
"Scardona Bay Viktor" <(E-Mail Removed)> wrote in
message news:46C050B8-C673-43D3-87A6-(E-Mail Removed)...
> 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!
> --
> SBR