views:

49

answers:

1

Hello,

I have a listbox in a Microsoft Access form. The MultiSelect property is set to simple.

I want to know which item in the listbox was clicked. Keep in mind that an item may be clicked to SELECT or UNSELECT an item.

Is there a simple way to do this? If not is there a complicated way to do this?

I tried to use the SendMessage windows API but no banana because Access controls do not support an hwnd property.

Seth

+2  A: 

If the MultiSelect proerty is None then just the value of the list box.

Debug.Print Me.List16

should be sufficient.

If you want the values of multiple columns

Debug.Print Me.List16.Column(0) & ", " & Me.List16.Column(1)

If the MultiSelect property is simple or complex then you need to loop through the ItemsSelected collection.

Dim varItm As Variant

For Each varItm In me.ListBx.ItemsSelected
    Debug.Print me.ListBox.ItemData(varItm)
Next varItm

Above is air code.

Tony Toews
Tony,I actually know all of that. What I want is different. I want to know which item was clicked. Basically I am hoping to real-time add/remove from a table based on which item is clicked. To do that I need to which specific item was clicked.Seth
Seth Spearman
I was wondering. Consider using two listboxes then with command buttons with arrows on the buttons. Identical in concept to the new Form Wizard where it has the list of Available Fields on the left hand side and Selected Fields on the righ thand side. We've used that interface in a number of situations and the users seem quite comfortable with it.
Tony Toews
I went with the add/remove paradigm and that is working well. Still wish you could know which item was clicked.Seth
Seth Spearman