PC Review


Reply
Thread Tools Rate Thread

closing all forms except switchboard

 
 
=?Utf-8?B?YmljeWNsb3Bz?=
Guest
Posts: n/a
 
      3rd Jun 2005
I've set up the following code

Dim frm As Access.Form
For Each frm In Application.Forms
If frm.Caption <> Screen.ActiveForm.Caption Then frm.Close
Next

The idea is to close all forms but the switchboard when the corresponding
button on the switchboard is pressed. I keep getting an error message: Run
Time Error 2465, and the program complains about the frm.close statement.

Is there a way to make this work or is there a better way to close all forms?

Thanks in advance.

 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      3rd Jun 2005
Loop backwards through the Forms collection, and use the Name to determine
which to leave open.

This kind of thing:

For i = Forms.Count -1 to 0 Step -1
If Forms(i).Name <> "Switchboard" Then
DoCmd.Close acForm, Forms(i).Name
End If
Next

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"bicyclops" <(E-Mail Removed)> wrote in message
news:91FA294E-C4F7-4F80-80FC-(E-Mail Removed)...
> I've set up the following code
>
> Dim frm As Access.Form
> For Each frm In Application.Forms
> If frm.Caption <> Screen.ActiveForm.Caption Then frm.Close
> Next
>
> The idea is to close all forms but the switchboard when the corresponding
> button on the switchboard is pressed. I keep getting an error message: Run
> Time Error 2465, and the program complains about the frm.close statement.
>
> Is there a way to make this work or is there a better way to close all
> forms?
>
> Thanks in advance.
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Switchboard and Closing Forms Novice2000 Microsoft Access Forms 4 30th Sep 2009 05:01 PM
Access not closing using Switchboard form mc Microsoft Access 3 31st Aug 2009 06:00 PM
closing the application with the switchboard exit =?Utf-8?B?aGVscCE=?= Microsoft Access Form Coding 2 25th Jan 2005 07:46 PM
closing all forms except main switchboard =?Utf-8?B?Z2VtbWEgY2hhcnRlcnM=?= Microsoft Access Forms 1 22nd Aug 2004 04:42 PM
Closing Access via Switchboard bill Microsoft Access 4 10th Mar 2004 05:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:39 PM.