Multi select combobox - order clicked?

GordonR

Registered User.
Local time
Today, 19:58
Joined
Aug 19, 2003
Messages
29
I have a multi select combobox which will contain a variety of remedial actions taken to a problem e.g. cleaned, repaired, replaced, removed, adjusted etc
I want to use these selections to automatically create some text so to make sense, the order of selection is important eg
removed, cleaned, refitted,tested
but the value of the control gets set to the values in the order they are presented in the control.
Can I detect the order they were individually selected?
Thanks!!
 
Gordon,

I think that you mean listbox, not combo, and sure you can do it
with some code. As each item is selected, you can concatenate
it to a string.

However, if they "unselect" one, that opens up a whole new set
of problems.

Wayne
 
In case this is of use to anyone else, here is how I dealt with this (forgive the quality of the code as I am new to all this)
I created the multi-selecatble list box 'List99' which gets its source from a query and a text box 'Text4' to receive the values (locked = yes)
The onclick event procedure for List99 then looks like this:
Private Sub List99_Click()
Dim frm As Form, ctl As Control, ctlx As Control
Dim sels As String
Dim sel As String
Dim l As Long
Dim p As Long

Set frm = Forms!SWR
Set ctl = frm!List99
Set ctlx = frm!Text4

If Not IsNull(ctlx) Then
sels = ctlx
End If

l = ctl.ListIndex
sel = DLookup("[Action]", "Actions", "[Action_id] =" & ctl.ItemData(l))

If ctl.Selected(l) = False Then
p = InStr(sels, sel)
If p > 1 Then 'not the first of the actions
sel = ", " & sel
Else 'is the first
If Not sel = sels Then 'still others left
sel = sel & ", "
End If
End If
sels = Replace(sels, sel, "")
Else
If Len(sels) > 0 Then
sels = sels + ", "
End If
sels = sels + sel
End If

ctlx = sels

Set ctl = Nothing
End Sub

As you can see, it handles clicks and unclicks. The ony thing I need to do is write a bit of code to allow the values to be stored in a table record. I realise that storing these values may go against the 'atomic' philosophy of databases but pragmatism rules in my world! I also recognise that the sorce table for List99 must not allow deletions.
 

Users who are viewing this thread

Back
Top Bottom