Table of contents
Collapse the table of content
Expand the table of content

Controls.Count Property (Access)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

You can use the Count property to determine the number of items in a specified collection. Read-only Long.


expression. Count

expression A variable that represents a Controls object.


The following example uses the Count property to control a loop that prints information about all open forms and their controls.

Sub Print_Form_Controls() 
 Dim frm As Form, intI As Integer 
 Dim intJ As Integer 
 Dim intControls As Integer, intForms As Integer 
 intForms = Forms.Count ' Number of open forms. 
 If intForms > 0 Then 
 For intI = 0 To intForms - 1 
 Set frm = Forms(intI) 
 Debug.Print frm.Name 
 intControls = frm.Count 
 If intControls > 0 Then 
 For intJ = 0 To intControls - 1 
 Debug.Print vbTab; frm(intJ).Name 
 Next intJ 
 Debug.Print vbTab; "(no controls)" 
 End If 
 Next intI 
 MsgBox "No open forms.", vbExclamation, "Form Controls" 
 End If 
End Sub

See also


Controls Collection

© 2018 Microsoft