Open record from List box

K

kharpe

I have a form with two multi-select list box that I would like to use to open
a specific record from. I have set up the list boxes so that i can move
items from one to the other, multiselection is so that I can move multiple
items at a time. Is there a way that I can use the ondoubleclick property
to open the individual item that I have double clicked on. My trouble is
with getting the primary key for the item out of the list box.
 
A

Arvin Meyer [MVP]

I'd just use the Click event, or you turn it on, then turn it off. Have a
look at this code:

With Me!lstElevation
If .MultiSelect = 0 Then
Me!txtSelected = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & ","
Next varItem
If strList <> "" Then
strList = Left$(strList, Len(strList) - 1)
End If
Me.txtSelected = strList
End If

End With

You can create a textbox (txtSelected) which is filled by strList, then use
that in an IN Clause in a SQL statement for a form's recordsource. The first
column of the list box has its columnwidth property set to 0" but it is the
bound value of the listbox.
 

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