Never mind. I figured it out. Below is a way to loop through all the loaded forms...
Sub CloseForms()
Dim i As Integer
For i = (Forms.Count - 1) To 0 Step -1
If Forms(i).Name <> "MainForm" Then
DoCmd.Close acForm, Forms(i).Name
End If
Next i
End Sub
Loop through the open forms (a form will be in the FORMS collection only if it is open). Change "MainForm" to the name you do not want to close. The loop must run in reverse since the form index numbers change when a form is closed (that is, if you close form(2), then all forms with a higher index are renumbered). If you try this code with the loop index running up from 0 it won't close all the forms.