David Gard
David Gard

Reputation: 12047

Extract selected rows from a Listbox in Access

In Access, I'm trying to extract the selected items from a List Box.

I haven't used the List Box object for a while, but I seem to remember that you have to loop through the selected items and then extract them using the List method.

My research supports this ascertation, but I'm running in to problems in relation to the use of List -

Compile error: Method or data member not found

Printing the lstLocations.Selected(i) sees -1 returned for every selection, and List apparently doesn't exist, so how can extract the selected values?

Dim i As Integer
For i = 0 To lstLocations.ListCount - 1
    If lstLocations.Selected(i) Then
        Debug.Print lstLocations.List(i)
    End If
Next i

Upvotes: 0

Views: 1264

Answers (1)

Krish
Krish

Reputation: 5917

use the for each loop to loop through the selected items. something like

        Dim item As Variant
        For Each item In Me.lbx_booking.ItemsSelected
            If Not (Nz(Me.lbx_booking.Column(0, item), "") = "") Then

            End If
        Next item

Upvotes: 1

Related Questions