VBA Code Examples

Examples of VBA

Close All Forms

Function



Public Function CloseOpenForms(Optional strExcept As String)
On Error Resume Next
Dim I As Integer
With Application.Forms
For I = .Count - 1 To 0 Step -1
With .Item(I)
If .Name = "Menu" Or .Name = "Welcome" Then
Else
DoCmd.Close acForm, .Name
End If
End With
Next I
End With
On Error Resume Next
vUser = [Forms]![Welcome]!UserSelect.Column(1)
vUserID = [Forms]![Welcome]!UserSelect
DoCmd.OpenForm "Menu"
DoCmd.Maximize
DoCmd.Requery

End Function

Back