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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listbox and Select Query

Status
Not open for further replies.

esengul

Instructor
Dec 9, 2004
59
US
i have a list box with multiselect option
i want to have a select query based on the items that user selects. the problem is it works with the last seleted item not all selected items. i don't know what i am doing wrong. Thanks

my code
For Each varItm In ctlanalytes.ItemsSelected
Debug.Print ctlanalytes.ItemData(varItm)
Next
sqlanalyte = "select " & ctlanalytes.ItemData(varItm) & " from tblanalyte"

 
I solved it. here is my code.
Dim strList As String
strList = ""

For Each varItm In ctlanalytes.ItemsSelected
strList = strList & ctlanalytes.ItemData(varItm) & ", "
Next
sqlanalyte = "select " & strList & " from tblanalytes"

thanks
 
sqlanalyte = ""
For Each varItm In ctlanalytes.ItemsSelected
sqlanalyte = sqlanalyte & "," & ctlanalytes.ItemData(varItm)
Next
If sqlanalyte <> "" Then
sqlanalyte = "select " & Mid(sqlanalyte, 2) & " from tblanalyte"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top