VBA/Excel/Access/Word/Forms/Forms

Материал из VB Эксперт
Версия от 15:48, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Loop through the documents in Forms

   <source lang="vb">

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

</source>
   
  


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

   <source lang="vb">

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

</source>