Link to home
Start Free TrialLog in
Avatar of Paul McCabe
Paul McCabe

asked on

MS Access -Close all forms except for one

MS Access 2013: My main navigation form has a handy button that closes all open forms using the following code:

Private Sub Btn_CloseAllForms_Click()
Dim intLoop As Integer
For intLoop = (Forms.Count - 1) To 0 Step -1
DoCmd.Close acForm, Forms(intLoop).Name
Next intLoop
End Sub

The problem is that it closes the main navigation form too, which I want to keep open.
I can re-open the form by inserting the following code just before End Sub:

DoCmd.OpenForm "F_Nav_Main", acNormal

This works, but closing and then re-opening the main navigation form does not seem like a very efficient
solution.  I have tried several other ways to exclude the main form from being closed, but cannot anything to work.
Can anyone think of a better way to do this ?
ASKER CERTIFIED SOLUTION
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Paul McCabe
Paul McCabe

ASKER

It works perfectly -Thank you !!!