View Full Version : Form closed when another one is open


Monica
06-07-2000, 02:20 PM
I have built a DB with 3 different forms how do get one form to close when I open a new one without click on the X to close it. I was told by a co-worker that this could be done and he was going to show me and was in an accident and will be out at least 3 weeks. Any suggestions or ideas.

Mitch
06-08-2000, 12:22 AM
In you event which opens the new form add a new line of code below the open statement -

Docmd.close acForm, "frmYourFormName"

HTH

Mitch.

Travis
06-08-2000, 12:29 PM
try this, add the following code to the Form_Open events of your forms.

Private Sub Form_Open(Cancel As Integer)
Dim frm As Form
For Each frm In Forms
If frm.Name <> Me.Name Then DoCmd.Close acForm, frm.Name
Next frm

End Sub


This will close all forms that are open except the currently being opened form.