[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

select and unselect a list box item

How can I select or unselect individual items in a multiselect list box?
0
calvinrsmith
Asked:
calvinrsmith
  • 2
  • 2
1 Solution
 
cekmanCommented:
Hold your CTL key down while you click your mouse
0
 
calvinrsmithAuthor Commented:
sorry, I meant in code.
0
 
cekmanCommented:
Here's my code to set a particular program name to selected. Hope it makes sense (see the VALUE property). Basically I search through my items if my list box - if I find the item that matches the value I'm looking for - I select it using the Value property.

Dim frm As Form
    Dim i As Integer
    Dim myCompare As Variant
    Set frm = Forms("frm_SCRPRMasterList")
    myCompare = frm![cmb_Programs]
        Set ctl = Me![cmb_Programs]
        varitem = ctl.ListCount
        For i = 0 To varitem - 1
            If myCompare = Val(ctl.Column(2, i)) Then
                ctl.Value = i
                Exit For
            End If
        Next i


You can also use the Select property

mylistbox.selected(indexnumber) = true

This will work in most cases - but in my example above - the Value property forced the list box to be POSITIONED at the selected field so if the value was way down the list - the user would see right away that it was selected.

CEKMAN
0
 
calvinrsmithAuthor Commented:
thanks
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now