Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I know which item in a mult-select Microsoft Access listbox was clicked?

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

like image 721
Seth Spearman Avatar asked Nov 17 '25 07:11

Seth Spearman


1 Answers

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.

like image 70
Tony Toews Avatar answered Nov 18 '25 19:11

Tony Toews



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!