is there a way to close all open forms

Anonymous
2025-05-01T16:11:21+00:00

Hi can you help?

i want to on close of a form close every form that may be open in background then go to a main screen.

if there a way to do this rather than added code to each form to close individually

thanks again

Microsoft 365 and Office | Access | For education | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2025-05-01T17:27:55+00:00

    Public Sub CloseAllForms()

        Dim n As Integer
        
        For n = Application.Forms.Count - 1 To 0 Step -1
            DoCmd.Close acForm, Forms(n).Name, acSaveNo
        Next n
        
        DoCmd.OpenForm "frmMainScreen"
    
    End Sub
    
    0 comments No comments