troubleshooting Question

Access VBA Get caption names without opening forms

Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft AccessVBA
2 Comments1 Solution21 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros