Closing and Opening Form at same time

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

Is it possible to open a form / close the current form at
the same time with a click of a command button? If so,
how? Thanks!
 
Dave

To open a form, use the Docmd.OpenForm command
To close a form, use the Docmd.CloseForm command

The help file will give you the specifics of each of the parameters
necessary.

HTH

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
I knew those were the commands..but, when I try to put
them both on the cmd_click function at the same time, only
the first one happens...meaning if i have open first, form
opens while other stays open and vise versa. Any ideas if
I can do both at the same time / same click?
 
Instead of Docmd.CloseForm just use Docmd.Close to close the current form.
The code should keep running so you can put the second command
Docmd.OpenForm.

Kelvin
 
Should that not work, hide the current form first by setting its Visible
property to False, then continue.
 
I knew those were the commands..but, when I try to put
them both on the cmd_click function at the same time, only
the first one happens...meaning if i have open first, form
opens while other stays open and vise versa. Any ideas if
I can do both at the same time / same click?

DoCmd.OpenForm "Form2"
DoCmd.Close acForm, Me.Name
 
I suppose one should ask why you need to do such a strange thing?

If you need to reload some data, or re-fresh some data, you can do this
without the need for closing, and re-opening the form.

Why such a strange request? What *really* is the problem here?

To re-load the data, you can go:

me.requery

To write the current record to disk, try:

me.Refresh

In 99% of the cases when some one asks how to close, and then re-open the
same form, they usually are trying to fix some problem that also get fixed
by exiting the form, and re-loading the form. I would re-state your problem
as to what it is you are trying to accomplish, as closing, and then
re-opening the same form is a bad bad idea.
 
Try closing the form first before opening the second

My example will work just fine as I am specifying the name of the form to close.
 
I am not closing the form and re-opening it...I am closing
the current form and opening a new form with one click.
By doing so, I refresh the form I am closing, and the new
form it opens will have curren data, instead of closing
form, then opening a new one.
 
Back
Top