ColumnCount Property
Applies To
Chart control, Combo Box control, List Box control, Table field, Unbound Object Frame control.
Description
You can use the ColumnCount property to specify the number of columns displayed in a list box or in the list box portion of a combo box, or sent to OLE objects in a chart control or unbound object frame. For example, if you set the ColumnCount property for a list box on an Employees form to 3, one column can list last names, another can list first names, and the third can list employee ID numbers.
Setting
The ColumnCount property holds an integer between 1 and the maximum number of fields in the table, query, or SQL statement, or the maximum number of values in the value list, specified in the RowSource property of the control.
You can set the ColumnCount property by using the control's property sheet, a macro, or Visual Basic.
For table fields, you can set this property on the Lookup tab in the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box or List Box.
Tip Microsoft Access sets the ColumnCount property automatically when you select Lookup Wizard as the data type for a field in table Design view.
Remarks
A combo box or list box can have multiple columns. If the control's RowSource property contains the name of a table, query, or SQL statement, a combo box or list box will display the fields from that source, from left to right, up to the number specified by the ColumnCount property.
To display a different combination of fields, create either a new query or a new SQL statement for the RowSource property, specifying the fields and the order you want.
If the RowSource property contains a list of values (the RowSourceType property is set to Value List), the values are put into the rows and columns of the combo box or list box in the order they are listed in the RowSource property. For example, if the RowSource property contains the list "Red; Green; Blue; Yellow" and the ColumnCount property is set to 2, the first row of the combo box or list box list will contain "Red" in the first column and "Green" in the second column. The second row will contain "Blue" in the first column and "Yellow" in the second column.
You can use the ColumnWidths property to set the width of the columns displayed in the control, or to hide columns.
See Also
BoundColumn property, Column property, ColumnHeads property, ColumnWidths property, ControlSource property, LimitToList property, RowSourceType, RowSource properties.
Example
See the Column property example.