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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Problem 1

Status
Not open for further replies.

jay2502

Technical User
Apr 20, 2007
25
A2
How Can make a form only close with code? I have taken the X (close button away) but can still right click on the window in the toolbar and close it how can i stop this?
 
Have a boolean value that is set to false (you set it to true in the code when you want to be able to exit) and in the form_unload event if the value is false then set the cancel flag which will stop the form unloading.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Thanks that makes sense but how would I do the Cancel flag?
 
Something like this:
Code:
Private Sub Form_Unload(Cancel As Integer)
If mblnCancel = False Then Cancel = -1
End Sub
That will stop the form unloading if the Boolean you set up is set to False.

Hope this helps


HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Thanks for the star, glad I could help [smile]

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top