[AccessD] MULTI SELECT LISTBOX dynamically selectingvaluesfromanother listbox

Tom Keatley tom.p at piedpiper.com.au
Thu May 4 04:32:19 CDT 2006


Hi All....

Many thanks go to Stuart McLachlan who supplied the code below to help me 
sort out a problem with a pair of multi-select list boxes I was working on.

I needed to select multiple items in a list box from a second list box. The 
other problem was I was working in A97 and did not have the split function

The second list box had the ID values of the table that was supplying the 
first list box in a field in the form 13771,13589,13654  etc

The Name of the second list box is DisBurseList

Thanks Stuart ....the problem I was having last of all was solved .... if 
you have a look at my precious email I had i dimmed as IntI as well and the 
code was trying to run with both variables ....of course it failed

I have posted this for the archives
thanks

Tom Keatley


'======================================================
Private Sub DisBurseList_Click()
       Dim i As Integer
       Dim strIDValue As String
       Dim lngCurrentValue As Long

       strIDValue =  "13771,13589,13654" 'DisBurseList '

        strIDValue = strIDValue & ","  'to pick up the last value in the 
loop below
Do
        lngCurrentValue = Val(strIDValue) 'get the first number
        strIDValue = Mid$(strIDValue, InStr(strIDValue, ",") + 1) 'get rid 
of the first number


        For i = 0 To Me!listcon1.ListCount - 1

             If Me!listcon1.ItemData(i) = lngCurrentValue Then
                Me!listcon1.Selected(i) = True
             End If
             Debug.Print Me!listcon1.ItemData(i) & " - " & lngCurrentValue

         Next i
Loop Until InStr(strIDValue, ",") = 0
End Sub
'=========================================================== 




More information about the AccessD mailing list