[AccessD] Close All Forms

Barbara Ryan BarbaraRyan at cox.net
Fri Aug 19 16:27:25 CDT 2005


That blew up, too.  The code has a reverse step only because I copied it
from someone else!

Barb

----- Original Message ----- 
From: "Charlotte Foust" <cfoust at infostatsystems.com>
To: "Access Developers discussion and problem solving"
<accessd at databaseadvisors.com>
Sent: Friday, August 19, 2005 4:36 PM
Subject: RE: [AccessD] Close All Forms


> Is there any particular reason you're using a reverse step in this?
> Have you tried it like this:
>
>            For i = 0 to Forms.Count - 1
>                 If Forms(i).Name <> "frmMainMenu" Then
>                     DoCmd.Close acForm, Forms(i).Name
>                 End If
>             Next i
>
> Does that also bail out on End Function?
>
> Charlotte Foust
>
>
> -----Original Message-----
> From: Barbara Ryan [mailto:BarbaraRyan at cox.net]
> Sent: Friday, August 19, 2005 11:52 AM
> To: Access List
> Subject: [AccessD] Close All Forms
>
>
> I have used the following code successfully in Access 97 to close all
> forms when a specific function key is pressed.  However, in Access 2002,
> this code causes the error box to appear (with the 2 options to send an
> error report to Microsoft or not) and then closes Access.  Does anyone
> know why?
>
>     Function CloseAllForms()
>         Dim i As Integer
>         ' Loop through the collection of open forms and close them
> (except for the main menu)
>         If Forms.Count > 0 Then
>             For i = Forms.Count - 1 To 0 Step -1
>                 If Forms(i).Name <> "frmMainMenu" Then
>                     DoCmd.Close acForm, Forms(i).Name
>                 End If
>             Next i
>         End If
>     End Function
>
> Thanks,
> Barb Ryan
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com




More information about the AccessD mailing list