[AccessD] Process multi-select listbox

artful at rogers.com artful at rogers.com
Mon Mar 5 10:29:36 CST 2007


Close, Rocky, but no cigar. I just figured it out, with your gentle prod in the right direction. The solution is:

<code>
'---------------------------------------------------------------------------------------
' Procedure : cmdProcess_Click
' DateTime  : 05/03/2007 11:24
' Author    : Arthur Fuller
' Purpose   : assemble column(0) multi-select choices from me.lstCities into a string
' Notes     : This requires Option Base 0 for the array to be declared in the Module Header.
'---------------------------------------------------------------------------------------
'
Private Sub cmdProcess_Click()
    Dim intCount As Integer
    Dim varItem As Variant
    Dim s As String
    On Error GoTo cmdProcess_Click_Error
    intCount = 0
    With Me
        intCount = .lstCities.ItemsSelected.Count
        If intCount = 0 Then Exit Sub ' Nothing selected.
    
        For Each varItem In .lstCities.ItemsSelected
            s = s & .lstCities.ItemData(varItem)
        Next varItem
        .txtResult = s
    End With
    On Error GoTo 0
    Exit Sub
cmdProcess_Click_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdProcess_Click of VBA Document Form_TestHarnessForTSPproblem_frm"
End Sub
</code>
 
Thanks for the prod,
Arthur 


----- Original Message ----
From: Rocky Smolin at Beach Access Software <rockysmolin at bchacc.com>
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Sent: Monday, March 5, 2007 10:11:25 AM
Subject: Re: [AccessD] Process multi-select listbox


Ooh. Ooh. I think I know this one.

    For Each varItem In lstOrders.ItemsSelected
        strList = strList & lstOrders.Column(0, varItem) & ";"
    Next varItem

Yes?

Rocky


More information about the AccessD mailing list