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.
|