Closing forms help please,

C

CEL504

Could someone please help me? I have read some of the threads relating to
closing forms, how and where do you write the code to close one form, when
you open another one. My example is, I have a switchboard form from where I
navigate around the database. Various buttons open the forms I need. How can
I get the previous form to close when a new one is selected. Do I write the
command on the button?

I have read some of the other threads, but just can't get my head around it
at the moment.

As ever, thanks for help and advice given.
Cel504
 
P

Piet Linden

Could someone please help me? I have read some of the threads relating to
closing forms, how and where do you write the code to close one form, when
you open another one.  My example is, I have a switchboard form from where I
navigate around the database. Various buttons open the forms I need. How can
I get the previous form to close when a new one is selected. Do I write the
command on the button?

I have read some of the other threads, but just can't get my head around it
at the moment.

As ever, thanks for help and advice given.
Cel504

In the button's click event that opens the next form, end the routine
with Me.Close
 
R

Rob Parker

If you're really wanting to control the user interface to prevent people
from having lots of different forms open at the same time - due to the
switchboard form being always available - then the easiest way is to hide
(rather than close) the switchboard form when another form is opened, and
show it again when the other form is closed. To do this, you'd use code
such as this:

In the event of the button on the switchboard form to open the new form:
Me.Visible = False
DoCmd.OpenForm "frmNewFormName"

In the close event of frmNewFormName:
Forms("frmSwitchboard").Visible = True
Putting this code in the Close event of the form ensures that it will always
run, regardless of how the user closes the form. If you've set up your form
(and menus) so that the user can only close the form via a command button
you have supplied, then you can put this code in the Click event of your
close button.

HTH,

Rob
 

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