ListRows Property

Applies To

Combo Box Control, Table Fields.

Description

You can use the ListRows property to set the maximum number of rows to display in the list box portion of a combo box.

Setting

The ListRows property holds an integer that indicates the maximum number of rows to display. The default setting is 8.

You can set this property using the combo box’s property sheet, a macro, Visual Basic, or the Combo Box Wizard.

For table fields, you can set this property in table Design view for fields with the DisplayControl property set to Combo Box.

Note Microsoft Access sets this property automatically when you select Lookup Wizard as the data type for a field in table Design view.

In Visual Basic, use a numeric expression to set the value of this property.

You can also set this property using a combo box’s default control style.

Remarks

If the actual number of rows exceeds the number specified by the ListRows property setting, a vertical scroll bar appears in the list box portion of the combo box.

See Also

Height, Width Properties; ListCount Property; ListWidth 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