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!

How to make click on 'X' close program?

Status
Not open for further replies.

robbaggio

Programmer
Jun 11, 2002
31
0
0
US
When i click on the exit button on my main form, it closes the program correctly. However when i click on the windows X button in the upper right(the close X next to the Maximize and Minimize), it closes the form, but task manager says the program is still running. Is there someway to fix this, like write a sub or something?

Any help would be greatly appreciated

robbaggio
 
Add "End" in Form_Terminate, it will execute any code that is in Form_Execute when you close that form via the X.... here is where you would add something like "Are you sure you wish to exit?"
 
I have always used the QueryUnload event, especially if I wanted to prompt the user. The Terminate event doesn't allow you to cancel the code but the QueryUnload event has a Cancel parameter that you can set to true if you wish to not cancel. I would also suggest unloading each form and setting the reference to nothing.


Like:

Unload frmMain
Unload frmWhatever

Set frmMain = Nothing
Set frmWhatever = Nothing

End
 
ok check this out.... sometimes you have interloped commands... which ends up keeping the program running because it is still processing stuff... this can happen with LONG commands and erhaps you forgot to take care of a loop or if statement... or in form query unload... you have fugged stuff up in there... make sure all your processes are closing correctly... ive had MANY problems liek this.. make sure all timers are stoped.. all forms are closed.. and all commands closed right and not interlopeing with others... if you need to post code or somehtign go for it and we could see whatsup.... gl! in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
Take a look at (I am assuming command button) your code for your exit command button. It sounds to me like you are releasing resources there that should be done in the QueryUnload or FormUnload event. You could also post the code in the exit procedure so we can take a look. [spin] If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top