Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to select ALL in a listbox

Status
Not open for further replies.

colezpapa

Programmer
Feb 26, 2007
86
US
Is there a way to select ALL in a listbox. Show ALL and then process all the items in the listbox.

I thought I saw this in some Access book...
Any ideas.
 
mark list as multiselect = 1 or 2
Code:
For intCurrentRow = 0 To ctlSource.ListCount - 1
   ctlSource.selected(intCurrentRow )=true
Next intCurrentRow

to select all rows
 
You can use a similar method to this faq702-4538
 
This is code that I use to process all items in a technician multi-line text box to add to an on-the-fly WHERE clause used to open a recordset later on. The concept of loading the elements into an array with the SPLIT function for processing could be used in your project:
Code:
Private Sub BuildTechWhere()

On Error GoTo TechError

    Dim arrTech() As String
    Dim intElement As Integer
    
    arrTech = Split(txtTechNum.Value, vbCrLf)
    If UBound(arrTech()) = 0 Then
        strTech = "pay_tech = '" & arrTech(0) & "'"
    Else
        strTech = "pay_tech IN("
        For intElement = 0 To UBound(arrTech())
            strTech = strTech & "'" & arrTech(intElement) & "'"
            If intElement <> UBound(arrTech()) Then strTech = strTech & ","
        Next intElement
        strTech = strTech & ")"
    End If
   
    Erase arrTech
   
    Exit Sub
    
TechError:
    MsgBox "Text box error " & Err.Number & vbCrLf & Err.Description

End Sub

Good Luck!

Before you criticize someone, you should walk a mile in their shoes.
That way, when you criticize them, you're a mile away and you have their shoes.
 
How are ya colezpapa . . .

have a look here 1st Adding an "ALL" option to a combo-box

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top