Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open new form,but close old form..

Status
Not open for further replies.

secretcrowds

Technical User
May 13, 2008
25
GB
I would like a command button on a form that does two things.
1.Opens up another form
2.Closes down the current form

So when the button is clicked, it opens a sepearte form, but closes down the current form. so that only one form is open at all times.

I have already done the code to make the button open another form, but i have hit a brick wall when it comes to making that same button close down the current form to open a new one.

Thank you for your help!

"secret crowds rise up and gather
 
Have you tried using the wizard to create command buttons? It is often useful as it creates sample code. In addition, it is always worth studying the Northwind sample database that ships with every version of Access. You will find that forms can be closed with DoCmd.Close.
 
The problem in your case lies in when and how you close the forms.


put then following code in each form, changing the form name accordingly

Private Sub Form_Close()
DoCmd.OpenForm "formname"
End Sub

so when you close the form it opens the next

alternatively you could open all forms and hide and make visible each form as you need them.

Ian Mayor (UK)
Program Error
Your lack of planning is not my emergency!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top