Form Close button

  • Thread starter Thread starter fran
  • Start date Start date
F

fran

Does anyone know how to disable the close button on a form
or create a form without a close button please
 
Here is another code snipit that accomplishes what you
want. In my case, this code routes the "x" close box to
the event routine which is run if the user clicks
the "Cancel" (cmdCancel) button allowing that routine to
decide whether or not to close the dialog.

Also, this routine suppresses the dialog from closing if
the user trys to quit Excel or shut down Windows while
the dialog is up. NOTE: any Cancel value other than 0
(or FALSE) suppresses the dialog from closing.

'Sub: UserForm_QueryClose
'Purpose: To intercept the UserForm's close event
'Arguments: Cancel As Integer, CloseMode As Integer
'Returns: none
'Called by:
'Notes: 1 = "stop the close event"
'Orig Date: 11/27/00 mss
'Rev Hist:
Private Sub UserForm_QueryClose(Cancel As Integer,
CloseMode As Integer)

'route the Close box in the title bar to the "Cancel"
button event
Select Case CloseMode
Case vbFormControlMenu
cmdCancel_Click
Cancel = 0
Case vbFormCode: Cancel = 0
Case vbAppWindows, vbAppTaskManager: Cancel = 1
End Select

End Sub
 
Back
Top