Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Select List Box Without Holding Down Ctrl 1

Status
Not open for further replies.

bpitche

MIS
Mar 13, 2001
43
US
I know how to create the multiple select list box! Is there a way to select multiple records with out holding down the control (ctrl) key?

Thanks in advance,

Brad
bpitche@hoover.com
 
Brad:

Set the Multiselect property of the list box to "Simple". This will allow the user to click on/off each item in the list to select.

Hope this helps.
Larry De Laruelle
larry1de@yahoo.com

 
Thank you Larry, that did the trick. I don't know why I did not think of that. My next question is, how would I write the code for a button to clear the selection in the list box?

Thank you,
Brad
bpitcher@hoover.com
 
Brad:

You might try setting its default value to Null in whatever click event you have where you want that to occur. I haven't tried it so I don't know if that will result in an error but its a place to start.
Larry De Laruelle
larry1de@yahoo.com

 
code snippets that i use. hope they help. SelectList is my simple multi-select listBox & i do it upon button click but it should be easy to change for your purposes
Code:
Private Sub SelectAllButton_Click()
    Dim i As Integer
    For i = 1 To Me.SelectList.ListCount - 1
        Me.SelectList.Selected(i) = True
    Next
End Sub

Private Sub DeselectAllButton_Click()
    Dim SelectItem As Variant
    For Each SelectItem In Me.SelectList.ItemsSelected
        Me.SelectList.Selected(SelectItem) = False
    Next
End Sub
 
for the SelectAllButton_Click routine i should tell you that there's a header line, that is the Column Heads property for the simple list box is set to yes... hence starting at 1 and not 0

other routine DeselectAllButton_Click will work either way as is
 
Rafe:

Used your deselect code in a project I'm working on. Works like a charm.

Thanks.
Larry De Laruelle
larry1de@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top