In a collection object, such as the ListItems collection from the ListView control, or simply a generic VBcollection object, you can specify a key to uniquely identify the item. Documentation states the key can beany String expression. What if the key needs to be a numerical string? In a ListView control, you might notset a numeric key. Even if you try to set a key equal to Str$(), you’ll receive an error message. Whendisplaying the results of a recordset with a ListView, the key would be the perfect place to hold the primarykey for the row, if applicable. Because ListView doesn’t have an ItemData property, the key is the onlyplace to hold it. The solution is simple: append the string “key” to your Numeric Key, and use the Valfunction to retrieve its value:
Set itemX = lvPeople.ListItems.Add_ (, , strName)'Set the KeyitemX.Key = Str$(rstPeople!PersonID) _ & "key" Use this code to retrieve the key:lKey = Val(lvPeople.ListItems_ (nIndex).Key))