Open Form on Menu then close old form

  • Thread starter Thread starter dmetcalf
  • Start date Start date
D

dmetcalf

Guest
I've a custom menu bar from which I can choose any of my forms. However when you choose a new form the old form stays open, sloppy in my mind. Is there any way i can choose the new form from the menu bar & close the previous form? I've tried to close on deactivate, w/ no luck.
 
The button you are clicking to open the new form. place the following code in the on click event.

Private Sub yourbutton_Click()
DoCmd.Close
DoCmd.OpenForm "yourformname"
End Sub

hope that helps
 
Try this solution (provided by Travis) which on opening a form will close all other 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
 

Users who are viewing this thread

Back
Top Bottom