[AccessD] Select all items in listbox and build sql string

Susan Zeller szeller at cce.umn.edu
Thu Apr 17 13:58:37 CDT 2003


I have some code from Arthur Fuller that makes a string out of all the
selected items in a listbox.  What I need now is to build a string out
of All the items in the listbox whether they are selected or not. I'm
not sure how to adapt the code I have.  I'm guessing I need to do For 0
to the number of items in the listbox in some way, but not sure of the
syntax for this.  Here's what I have now:

    Dim intI As Integer, intX As Integer
    Dim strSQL As String
    
        With ctl
            For intI = 0 To .ItemsSelected.Count - 1
                intX = ctl.ItemsSelected(intI)
                If intI > 0 Then
                    strSQL = strSQL & ",'" & ctl.Column(0, intX) & "'"
                Else
                    strSQL = "'" & ctl.Column(0, intX) & "'"
                End If
            Next intI
        End With

-Susan


Susan B. Zeller
Office of Information Systems
College of Continuing Education
University of Minnesota
306 Wesbrook Hall
77 Pleasant Street SE
Minneapolis, MN 55455
Phone:  612-626-4785
Fax:  612-625-2568




More information about the AccessD mailing list