Link to home
Create AccountLog in
Avatar of Murray Brown
Murray BrownFlag 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
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Murray Brown

ASKER

Thanks