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

Application quit event..

Status
Not open for further replies.

mike777

Programmer
Jun 3, 2000
387
US
Is there a way to fire a procedure when the application closes without using a form??
Thanks.
 
You could call this:

Public Sub QuitAll()
'some code here
Application.quit
End Sub



 
Mike,

The way this is typically done is to have a startup form (in tools|Startup) that never closes. You canuse this as your switchboard form. When the user moves on to another form or to a report, this switchboard form is not closed, it is only ever made invsible.

Put code something like this in the unload event of the form:

Private Sub Form_Unload(Cancel As Integer)

if me.tag = "OKtoQuit" then
application.quit
else
msgbox "can't quit this"
cancel = true

end if

End Sub

Put a button on this form to quit the application, and in the code under that button, set the tag of the form before calling application.quit.

You'll want to make the message box a heck of a lot more informative, of course, and and error handling, but that's the basis of how it's usually done.

That way, no matter what object is being viewed, as long as that switchboard form is open, it will be impossible to quit the application any way other than hitting the quit button (or the 3-finger salute or the power button of your pc, of course).

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top