ItemData Property Example

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