Avatar of Murray Brown
Murray Brown
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Access VBA Get caption names without opening forms

Hi. I am using the following code to list all the caption names of forms. Is there any way to do this without opening each form? Thanks

Sub oLoadFormsToCombo()

    On Error GoTo EH
   
        Dim frm As Object
        Dim I As Integer
       
        For I = Me.cmbFormNameAndCaption.ListCount - 1 To 0 Step -1
            Me.cmbFormNameAndCaption.RemoveItem (I)
        Next I
       
        Me.cmbFormNameAndCaption.SetFocus
        Me.cmbFormNameAndCaption.Text = ""
        Me.cmbFormNameAndCaption.AddItem ("")
        For Each frm In CurrentProject.AllForms
            Me.Form_Name.AddItem (frm.Name)
            If frm.Name <> Me.Name And frm.Name <> "f_Login" And frm.Name <> "f_MainOptions" Then
                DoCmd.OpenForm frm.Name, acDesign, , , , acHidden
                Me.cmbFormNameAndCaption.AddItem (Forms(frm.Name).Caption)
                DoCmd.Close acForm, frm.Name
            End If
        Next
       
       
    Exit Sub
EH:
    MsgBox "Error loading forms: " & Err.Description
   
End Sub
Microsoft AccessVBA

Avatar of undefined
Last Comment
Murray Brown

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Murray Brown

ASKER
Thanks
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes