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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for a Multiselect listbox specific value

Status
Not open for further replies.

Jackie

MIS
Feb 9, 2000
148
US
How do I check for a specific value in a multiselect listbox? I have a multiselect listbox. I would like to "clear" the listbox if the user selects "None". "None" is included in the listbox record source. I would like to include an If statement that checks the value of the multiselect option selected. If the value is "None", I will set the listbox value to " ".
 
Hi!

Use the following code to see what was selected:

Dim ListRow As Variant
Dim cntl As Control

Set cntl = Me!YourListBox

For Each ListRow in cntl.ItemsSelected
If cntl.Column(0, ListRow) = "None" Then
Whatever you want to do here
End If
Next ListRow

Set cntl = Nothing

It may be more effective to use a Select Case statement instead of the If to give yourself more flexibility. Also, I assumed that the value you are looking for is in the first column of the list box, if it isn't you will need to change the 0 to the appropriate column.

hth
Jeff Bridgham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top