closing all forms

C

cinnie

greetings

My Main Menu form has an Exit button with the following code:

Private Sub cmdExit_Click()
CloseCurrentDatabase
End Sub

But this crashes when there are other forms open on the screen. What code
can I use that will close ALL forms that are currently open. (they could be
visible or not)

thank you - Cinnie
 
D

Dirk Goldgar

cinnie said:
greetings

My Main Menu form has an Exit button with the following code:

Private Sub cmdExit_Click()
CloseCurrentDatabase
End Sub

But this crashes when there are other forms open on the screen. What code
can I use that will close ALL forms that are currently open. (they could
be
visible or not)

thank you - Cinnie


There is code that will close all the open forms, but I wonder if that's
really what you need to solve your problem? Is the intention of your Exit
buton to to exit the Access application entirely? If so, then
CloseCurrentDatabase isn't really the method you want to use. You might use

DoCmd.Quit

or

Application.Quit

to better effect. Either of those methods would close all currently open
forms without any other work on your part.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top