Count Property

See Also16G8D6T

Applies To

Forms collection1MV9U5Q, Controls collectionB2IKWH, Fields collectionQ15ZEN, Indexes collection1WAT5K, TableDefs collection2CHOSZ.


         Forms collectionspecifies the number of loaded forms.

         Controls collectionspecifies the number of controls on a form, including menus and menu items.

         Fields, Indexes, TableDefs collectionsspecifies the number of objects in the collection.


Not available at design time; read-only at run time.





tabledef | recordset}.Fields.Count

table | tabledef}.Indexes.Count


You can use this property in a For...NextLANFOR loop to specify the number of forms or controls in a collection.  For example, the following code would move all controls on a form one-half inch to the right (ScaleMode5SNY0BP = 0):

For I = 0 To Form1.Count - 1
  Form1.Controls(I).Left = Form1.Controls(I).Left + 720
Next I

You can also use this kind of structure to quickly enable or disable all controls on a form.

When used with the If TypeOfLANIF statement, you can cycle through all controls and change, for example, the values of only the text boxes, or the BackColor1W9T6JQ setting of all the option buttons.

Data Type


See Also


Count Function (SQL Only)7CZVIA

RecordCount PropertyCVBV42

Programmer's Guide:

Chapter 8, "Objects and Instances"