PC Review


Reply
 
 
=?Utf-8?B?ZHVzdGlubDE1?=
Guest
Posts: n/a
 
      7th Dec 2006
I have a button on a form, what I want to do is when the button is pushed
close ALL open forms, reports, tables, EXCEPT one form (this one form opens
when you open the database and I want it to stay open the entire time).

Is it possible to do something like this with the docmd.close or a different
way.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGFtaWFuIFM=?=
Guest
Posts: n/a
 
      7th Dec 2006
Hi dustin15,

Yes, you can use docmd.close if you use the following syntax:

docmd.close acForm, FORMNAME

where FORMNAME is the name of the form that is open.

If you put it in a loop you could cycle through all forms and check if it's
open, closing it as above if it is.

Damian.

"dustinl15" wrote:

> I have a button on a form, what I want to do is when the button is pushed
> close ALL open forms, reports, tables, EXCEPT one form (this one form opens
> when you open the database and I want it to stay open the entire time).
>
> Is it possible to do something like this with the docmd.close or a different
> way.

 
Reply With Quote
 
Rick Brandt
Guest
Posts: n/a
 
      7th Dec 2006
"dustinl15" <(E-Mail Removed)> wrote in message
news:3BD02F9B-01D5-4017-87F4-(E-Mail Removed)...
>I have a button on a form, what I want to do is when the button is pushed
> close ALL open forms, reports, tables, EXCEPT one form (this one form opens
> when you open the database and I want it to stay open the entire time).
>
> Is it possible to do something like this with the docmd.close or a different
> way.


You need to loop through the Forms collection backwards testing the name of each
form. If the name is the form you don't want to close then skip that one. The
indexes of the Forms collection change as you close forms. That is why you have
to loop backwards.

If as you say the one to not close is the first form opened at startup then it
should be at index zero, but I would still test the name property to be certain.


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


 
Reply With Quote
 
Larry Daugherty
Guest
Posts: n/a
 
      7th Dec 2006
To answer your question as asked, yes, docmd can do the job but you'd
want to first test that the current form in the 'closeit loop" is not
the one you want kept open.

The way you asked your question causes me to wonder if you're looking
for a faux Autoclose macro. If you already have the code you want to
run placed in the close event of that form then you can simply put
Application.Quit in your command button. Since the form of interest
is the first one opened, in the absence of other direction, Access
will close open forms in inverse order of their opening. i.e. that
first opened form will be the last form closed.

HTH

--
-Larry-
--

"Damian S" <(E-Mail Removed)> wrote in message
news:24945971-8823-4039-ADF2-(E-Mail Removed)...
> Hi dustin15,
>
> Yes, you can use docmd.close if you use the following syntax:
>
> docmd.close acForm, FORMNAME
>
> where FORMNAME is the name of the form that is open.
>
> If you put it in a loop you could cycle through all forms and check

if it's
> open, closing it as above if it is.
>
> Damian.
>
> "dustinl15" wrote:
>
> > I have a button on a form, what I want to do is when the button is

pushed
> > close ALL open forms, reports, tables, EXCEPT one form (this one

form opens
> > when you open the database and I want it to stay open the entire

time).
> >
> > Is it possible to do something like this with the docmd.close or a

different
> > way.



 
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
Form does not close on DoCmd.Close acForm, Me.Name Chrisso Microsoft Access Form Coding 1 18th Nov 2008 06:23 PM
docmd.close forms - doesn't close the form Wuelf Microsoft Access Reports 1 18th Nov 2008 01:05 PM
Help with "Form DoCmd.Open and DoCmd.Close Ayo Microsoft Access 9 11th Dec 2007 06:04 PM
When I close a form with DoCmd.Close I get a parameter popup Robert Microsoft Access 1 14th Jul 2007 05:54 PM
DoCmd.Close and DoCmd.DeleteObject Daniel Magnus Bennét Björck Microsoft Access Form Coding 12 25th May 2004 08:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:51 PM.