Closing and Opening Form at same time

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!
 
R

RobFMS

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

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
D

Dave

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?
 
K

Kelvin

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
 
W

Wayne Morgan

Should that not work, hide the current form first by setting its Visible
property to False, then continue.
 
B

Bruce M. Thompson

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
 
A

Albert D. Kallal

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

Bruce M. Thompson

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

Dave

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top