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 ?
Paul McCabeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
Private Sub Btn_CloseAllForms_Click()
Dim intLoop As Integer
For intLoop = (Forms.Count - 1) To 0 Step -1
if Forms(intLoop).Name = "F_Nav_Main" then
else
DoCmd.Close acForm, Forms(intLoop).Name
end if
Next intLoop
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Paul McCabeAuthor Commented:
It works perfectly -Thank you !!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.