VBA/Excel/Access/Word/Forms/Forms

Материал из VB Эксперт
Перейти к: навигация, поиск

Loop through the documents in Forms

 
Sub exaFormsContainer()
 
    Dim db As Database
    Dim frm As Form
    Dim doc As Document
     
    Set db = CurrentDb
     
    Debug.Print "Opened form count: " & Forms.Count
    For Each frm In Forms
       Debug.Print frm.Name
    Next
    Debug.Print
     
    Debug.Print "Saved form count: " & db.Containers!Forms.Documents.Count
    For Each doc In db.Containers!Forms.Documents
       Debug.Print doc.Name
    Next
     
End Sub



Use the form object variable to point at each form in the Forms collection

 
Sub IterateOpenForms()
    Dim frm As Form
    
    For Each frm In Forms
        "Print the name of the referenced form to the Immediate window
        Debug.Print frm.Name
    Next frm
End Sub