Auto Form Close

  • Thread starter Thread starter SiH23
  • Start date Start date
S

SiH23

I have a button on a form which opens up a second form when pressed. The
problem however is that original form stays open behind it. How can I
automatically open and then close the previous form from a single button?
 
SiH23 said:
I have a button on a form which opens up a second form when pressed.
The problem however is that original form stays open behind it. How
can I automatically open and then close the previous form from a
single button?

Add one line of code to what is already there...

DoCmd.Close acForm, Me.Name
 
It may be that you are passing data from the 1st form to the 2nd so open the
2nd before you close the 1st - like this


Private Sub ButtonName_Click()
DoCmd.OpenForm "Form2", acNormal, "", "", , acNormal
DoCmd.Close acForm, "Form1"
End Sub


This will not filter the 2nd form - you can add filters to the code above if
you want. - ie. Open form the a certain record, etc

Good luck
 

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

Back
Top