How you would close the previous form depends on how you open the new form.
If you open it from the previous form, you could just have that form close
itself once it opens the new form. If you open the new form from the
switchboard though, you'll have to make a check to see what form(s), if any
are open then close them. If you maintain hidden forms, you probably won't
want to close them. The following is an example of a routine that should
test for open forms and close them.
Example:
Dim i As Integer
For i = Forms.Count - 1 To 0 Step -1
If Forms(i).Name <> Me.Name And Forms(i).Name <> "Switchboard" And
Forms(i).Visible Then
DoCmd.Close acForm, Forms(i).Name, acSaveNo
End If
Next
Replace Switchboard with the name of your switchboard form if it stays open
all of the time. You could do this in the Open event of each form you open
or you could place this in a module and call the routine in the module,
passing the name of the form being opened and replacing Me.Name with the
passed information.
A For/Next loop doesn't work to close the forms because it starts at the low
index and counts upward. The problem is that Access rolls the index number
of the remaining open forms down one each time a form is closed, so you wind
up only closing about 1/2 of the forms if you use a For/Next loop.