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

close all forms on exit button click

Status
Not open for further replies.

MBall2003

Programmer
May 30, 2003
61
US
I want to close all open forms when a user presses the exit button is there an easier way than docmd.close "allformnames" here


any help would be appreciated thanks

mball
 
Do you want to close the Access app as well ?

If so use
DoCmd.Quit


'ope-that-'elps.



G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
yes. on click of exit i want to quit access thanks


one other quick question in an if statement how do i find out if a form is open

like

if( frmMain.open()) then

....

end if
thanks


mball
 
The term you need is "Loaded"

As in

Code:
If CurrentProject.AllForms("YourFormNameHere").IsLoaded Then


:)



G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
Might I add on to this another question...

Is it ok to NOT close any open forms before quitting? It seems to be fine for me...I have a few places where there are forms that are open but not visible, and yet I have an Exit button with only this onClick event:

DoCmd.Quit

And it doesn't seem to cause me any trouble that I don't first close any open forms. (This isn't in places where people are doing data entry.) Is this bad practice? Should one always close any open forms? And if any body is up to the explanation....why?

Thanks

 
If I want to close all the open forms in an application I just loop thru all the forms and attempt to close each one. As no error is generated if you attempt to close a form that isn't open this is simple and works fine. I place this code in a public sub e.g.
Code:
    Dim myDoc As Document
    Dim dbPayroll As DAO.DataBase
    Set dbPayroll = CurrentDb
    For Each myDoc In dbPayroll.Containers!Forms.Documents
       DoCmd.Close acForm, myDoc.Name
    Next myDoc
[\code]
 
Sohunter, there is really no big deal about making sure your forms are all closed before you exit an application. Remember, closing a form will 'commit' any pending changes, and unless you have a user who fills out a form and then stays on the last field, it should be no big deal.

I have several apps that might have 'hidden' forms floating around during the course of the day, and have not had any problems with an "application.quit" button on my main menu...

JMH

If at first you don't succeed, skydiving probably isn't for you!
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top