Are all the forms closed now?

Randomblink

The Irreverent Reverend
Local time
Today, 14:31
Joined
Jul 23, 2001
Messages
279
I have a Public Function that I use to close ALL my forms.
My problem is...I also have a Function that Hides the access Window. So if the last form visible is closed...then Access still runs, but it is empty...argh!

Well, I want to add a line to the close function to check for all open forms...

If there are no open forms, I want to:
Application.Quit acCloseSaveAll

Can anyone help me?

I don't know how to check to see if there are any forms open?
 
I do not know what function you have but this works for me...

Do While Forms.Count > 0
DoCmd.Close acForm, Forms(0).Name
Loop

DoCmd.RunCommand acCmdExit


I tested it by opening three forms (two were hidden) and the database window was also hidden.

When I ran the above function from a command button, the db and Access 97 closed (completely).

HTH
 
Test if FormA is opened...

For those in need, this will test if FormA is opened...

If IsFormOpen("FormA") = True Then
MsgBox "Form A is open"
Else
MsgBox "Form A is not open"
End If

You can alter the code to test for Tables, reports, etc...

HTH
 

Users who are viewing this thread

Back
Top Bottom