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

ListBox.ItemData Property (Access)

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

The ItemData property returns the data in the bound column for the specified row in a list box. Read-only Variant.


expression. ItemData( ** Index** )

expression A variable that represents a ListBox object.


NameRequired/OptionalData TypeDescription
IndexRequiredLongThe row in the combo box or list box containing the data you want to return. Rows in combo and list boxes are indexed starting with zero. For example, to return the item in the sixth row of a combo box, you'd specify 5 for the rowindex argument.


The ItemData property enables you to iterate through the list of entries in a combo box or list box. For example, suppose you wanted to iterate through all of the items in a list box to search for a particular entry. You can use the ListCount property to determine the number of rows in the list box, and then use the ItemData property to return the data for the bound column in each row.

You can also use the ItemData property to return data only from selected rows in a list box. You can iterate through the ItemsSelected collection to determine which row or rows in the list box have been selected, and use the ItemData property to return the data in those rows. You must set the MultiSelect property of the list box to Simple or Extended to enable the user to select more than one row at a time.

You can use the Column property to return data from a specified row and column, even if the specified column isn't the bound column.


The following example prints the value of the bound column for each selected row in a list box EmployeeList on an Employees form. The list box's MultiSelect property must be set to Simple or Extended.

Sub RowsSelected() 
 Dim ctlList As Control, varItem As Variant 

 ' Return Control object variable pointing to list box. 
 Set ctlList = Forms!Employees!EmployeeList 
 ' Enumerate through selected items. 
 For Each varItem in ctlList.ItemsSelected 
 ' Print value of bound column. 
 Debug.Print ctlList.ItemData(varItem) 
 Next varItem 
End Sub

See also


ListBox Object

© 2017 Microsoft