Setting values in a multi-select list box.

C

Craig

I'm trying to select a particular value in a multi-select list box. I have a
search function that searches the records in a multi-select list box and
returns the value of the first item that matchs the search string. It then
selects this item in the list box for the user. The problem is, it works
fine when the list box's Multi-select property is set as NONE. But when I
select SIMPLE or EXTENDED, it doesn't work. Instead, no records are
selected. It also appears the default value property doesn't work either.
Any suggestions on getting around this?

Craig
 
V

Van T. Dinh

Multi-Select ListBox always has Null Value and you cannot set the Value of a
Multi-Select ListBox.

It sounds like you can use the Property "Selected" of the Multi-Select
ListBox. Check Access Help on this Property which has sample codes.
 
D

Douglas J. Steele

Here's sample code from the Help file:

Sub BoundData()
Dim frm As Form, ctl As Control
Dim varItm As Variant

Set frm = Forms!Contacts
Set ctl = frm!Names
For Each varItm In ctl.ItemsSelected
Debug.Print ctl.ItemData(varItm)
Next varItm
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top