I have a database with several forms.
I wanted a vba code that could close all the forms except two forms: “frm_login” and “HIDE”
Searching around, I came across these codes;
Dim F As Access.Form
Dim i As Long
' Loop all open forms, from last to first, to avoid problems due to closing forms
' (removing them from the Forms collection) in the loop
For i = Forms.Count - 1 To 0 Step -1
Set F = Forms(i)
' Close all forms except the login form
If F.Name <> "frm_login" Then
DoCmd.Close acForm, F.Name
End If
Next i
End Sub
Unfortunately, this code will close all forms except only the “frm_login”.
Would be glad if I could get help to modify the code so it will close all forms except the “frm_login” and the “HIDE”