ListCount Property

Applies To

Combo Box Control, List Box Control.

Description

You can use the ListCount property to determine the number of rows in a list box or the list box portion of a combo box.

Setting

The ListCount property holds the number of rows in the list box or the list box portion of the combo box. The value of the ListCount property is read-only and can’t be set by the user.

This property is available only in Visual Basic. You can read this property only in Form view and Datasheet view.

Remarks

You can use the ListCount property with the ListRows property to specify how many rows you want to display in the list box portion of a combo box.

See Also

ListIndex Property, ListRows Property, ListWidth Property, Selected Property.

Example

This example uses the ListCount property to find the number of rows in the list box portion of the CustomerList combo box on a Customers form. It then sets the ListRows property to display a specified number of rows in the list.


Sub SizeCustomerList()
    Dim ListControl As Control
    Set ListControl = Forms![Customers]![CustomerList]
    If ListControl.ListCount < 8 Then
        ListControl.ListRows = ListControl.ListCount
    Else
        ListControl.ListRows = 8
    End IfSub