List box Property for All items in list

mickmullen

Registered User.
Local time
Yesterday, 22:27
Joined
Oct 30, 2018
Messages
19
I'm looking to build a string in VBA


I have successfully implemented code using Listbox.itemsSelected


However, I am now trying to build a string that uses all of the items in the list box, when none are selected. I am having trouble locating what property I should be using


For Each varItem In Me!ListRmNum.(??Each Item in the List??)



I'm not sure that varitem is used correctly here. looking to build a string of all items in the list box


Similar to this, but I want all items returned rather then just the selected (Note- in this scenario, no items will be selected)

Code:
For Each varItem In Me!ListRmNum.ItemsSelected
            'add the chkExclude checkbox
            If (Me!chkExcludeRoom = False) Then
                strCriteria = strCriteria & "[Estimate Data.room Number] = " & Chr(34) _
                          & Me!ListRmNum.ItemData(varItem) & Chr(34) & " OR "
            Else
                strCriteria = strCriteria & "[Estimate Data.room Number] <> " & Chr(34) _
                          & Me!ListRmNum.ItemData(varItem) & Chr(34) & " AND "
            End If
        Next varItem
 
Hi,


If you have a simple list, all the items are in its RowSource property. Otherwise, you can use a loop to grab each item like so:


Code:
For x = 0 To Me.ListboxName.ListCount - 1

     strVariable = strVariable & Me.ListboxName.ItemData(x)


 Next x
Hope it helps...
 

Users who are viewing this thread

Back
Top Bottom