[RESOLVED] Programing the X (exit) button
Hello,
In the Right hand top corner of every page is a X (Exit) button.
Is there anyway to program the code for this?
The reason I ask is because when I click it (On my program's window) It closes the app BUT does not close it in the Taskmanager window.
Thank you for any help you may have!
Stilekid007
Re: Programing the X (exit) button
If you have more than one form open you'd have to loop throyugh forms collection and close each form before you unload your main form. Also each form (upon closing) must destroy all object variables including (but not limited to) connection/recordsets/collections/etc...
VB Code:
Private Sub Form_Unload
Dim frm As Form
Form Each frm In Form
If Not frm.name = Me.Name Then
Unload frm
End if
Next frm
End Sub
Re: Programing the X (exit) button
Ah,
I see,
Thank you for that information!
Stilekid007
Re: Programing the X (exit) button
You should actually use the queryunload event for unloading all forms to quit an app. This event is raised when you click on the x button.
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
End Sub
Re: Programing the X (exit) button
Quote:
Originally Posted by RobDog888
You should actually use the queryunload event for unloading all forms to quit an app. ...
Not necessary. It's mainly usefull if you don't want user to quit "prematurely"...
Re: Programing the X (exit) button
Not necessarily true as if the system shuts down unexpectedly you can catch it by evaluating the Unload Mode parameter. Same for Windows session ending and other events. ;)
Re: Programing the X (exit) button
Ok, Great!
Thank you so much guys!
Stilekid007
Re: Programing the X (exit) button
Quote:
Originally Posted by RobDog888
Not necessarily true as if the system shuts down unexpectedly you can catch it by evaluating the Unload Mode parameter. Same for Windows session ending and other events. ;)
It is true - if app is shut down "unexpectedly" then what do you care about QueryUnload mode ... ;)
Re: [RESOLVED] Programing the X (exit) button
Like if you have an open connection to an Access database which when unexpedly terminated can cause databaase corruption. ;)
Re: [RESOLVED] Programing the X (exit) button
Common really... terminating application/connection doesn't cause any corruption ... are you kidding me?
Re: [RESOLVED] Programing the X (exit) button
Obviously you havent worked with as many Access dbs as I have. I have seen it happen several times over the past few years. Now granted it may not happen every single time but if you dont have a backup and cant repair the db after a corruption, I'll bet you will wish you would have done all you could have to protected it instead of loosing your db and data. ;)
Re: [RESOLVED] Programing the X (exit) button
Quote:
Originally Posted by RobDog888
[color=navy]Obviously you havent worked with as many Access dbs as I have. ...
Not to offend you but you havent even seen that many yet. :wave: ;)
But I wish we can stop this quite useless conversation. Sorry.
Re: [RESOLVED] Programing the X (exit) button