PDA

View Full Version : Listbox: Cannot access selected Item



toom
04-16-2011, 08:39 AM
I got a listbox call "listKunden". In my particular case the listbox contains 4 items. If I set a breakpoint in my code and add listKunden to the watch I can verify that listKunden->RecordSet->Item 2->value contains the value I am looking for. Therefore I wrote the following code:

If Form_Kundensuche.listKunden.ItemsSelected.Count = 1 Then
listKunden.ItemData(listKunden.ItemsSelected(0))

So the listKunden list box has exactly one selected item. But "listKunden.ItemData(listKunden.ItemsSelected(0))" always returns null.
While "listKunden.ItemsSelected(0)" returns the correct row index of my list box.

Why does this happen?

toom
04-16-2011, 08:58 AM
I found out how to do it:
Now I use the following code fragment to retrieve the value I'm looking for
strId = listKunden.Column(1, listKunden.ItemsSelected(0))

But one question remains: Why does the code above not work? Maybee because I'm using Access 2010 and the code above is deprecated?