Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Open & closing forms

0 views
Skip to first unread message

PaulW

unread,
Jul 21, 2002, 3:39:08 PM7/21/02
to
Hello newsgroup guru's and users.

Your kind assistance please.

In the interest of reducing the amount of forms I have on
screen any any given time, is it possible to go back to
the last form that was open after the present form has
been shut down.

In my db i have many docmd.open form with were conditions,
which all work fine. The problem is I seem to have alot of
forms on screen with one on top of another. This can start
to look messy and confusing for the user.

If anyone can point me in the right direction, I would be
greatful.

Regards PaulW.

fredg

unread,
Jul 21, 2002, 4:23:19 PM7/21/02
to
Paul,
Open the second form with an OpenArgs argument and close
the first form at the same time:

DoCmd.OpenForm "Form2Name", , , , , , Me.Name
DoCmd.Close acForm, Me.Name

Then when you close that 2nd form you can go back to the first form
by coding the 2nd form's Close event:
DoCmd.OpenForm Me.OpenArgs

--
Fred

Please reply only through this newsgroup.
I do not reply to direct e-mails.


PaulW <to...@nyspammers.com> wrote in message
news:1a85e01c230ee$480322f0$9ae62ecf@tkmsftngxa02...

paul

unread,
Jul 21, 2002, 4:46:24 PM7/21/02
to
Here's what I tried and it worked.

I created a Class Module called Module1 with the following
code. Notice the Global variable declaration:

---begin code sample---
Option Compare Database
Option Explicit
Global strFormName As String

Public Sub FormName()
strFormName = Screen.ActiveForm.Name
End Sub
---end sample---

Then in the On Close event of your first form you can add
the code:

Module1.FormName

which stores the current form name as a variable.

In the On Close event of any subsequent forms, use the code

DoCmd.OpenForm strFormName
Me.SetFocus
Module1.FormName

which will open up the form whose name is now stored
memory and then store the current form's name.

I don't know how clear that explanation is. Repost if you
have questions.

Also, there may be an easier/better way, but this one
works.

>.
>

PaulW

unread,
Jul 21, 2002, 6:28:50 PM7/21/02
to
Two equally good responses.

Thanks guys.

Pat Hartman

unread,
Jul 21, 2002, 9:52:27 PM7/21/02
to
I use the OpenArgs argument to pass the current form name
to the one that I am opening and rather than closing the
current form, I hide it so that I can backtrack
completely along a path of forms.

To pass the current form name:
DoCmd.OpenForm "YourFormName",,,,,,Me.Name

To go back to the form that opened this one:
DoCmd.OpenForm Me.OpenArgs

>.
>

0 new messages