Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling the closing of a window

Status
Not open for further replies.

grahamnewlands

Programmer
Dec 11, 2000
4
AU
How to I prevent a user from closing a window/form. I want the user to instead press a button on the form rather than have them being able to close the window. Any ideas as I've looked at the properties for a window and can't seem to work it out....
 
Option Explicit
Dim Quit As Boolean

Private Sub Command1_Click()
Quit = True
Unload Me
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If Not Quit Then Cancel = 1
End Sub

David Paulson


 
Set the ControlBox property of the form to False. Unfortunately with this, you also lose the minimise and maximise buttons, along with the close button (in the top right corner of the form)

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top