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!

Query with multi listbox 1

Status
Not open for further replies.

Domino2

Technical User
Jun 8, 2008
475
GB
I am trying to get my where statement to work in a query where the where clause gets values from a multi select listbox.

For i = 0 To List14.ListCount - 1
If List14.Selected(i) Then
strIN = strIN & "'" & List14.Column(0, i) & "',"
End If
Next i

strWhere = " WHERE [ID3] in (" & Left(strIN, Len(strIN) - 1) & ")"

strSQL = "SELECT PARTNERS.ID1, ACTIVITIES.ID3, PROGRESS.ID4, PARTNERS.Partner, ACTIVITIES.[Date Raised],"
strSQL = strSQL & " ACTIVITIES.[Date Closed], ACTIVITIES.Status, ACTIVITIES.Type, ACTIVITIES.RequestedBy,"
strSQL = strSQL & " PROGRESS.[Updated On], PROGRESS.Something1, PROGRESS.Something2, PROGRESS.Something3"
strSQL = strSQL & " FROM (PARTNERS INNER JOIN ACTIVITIES ON PARTNERS.ID1 = ACTIVITIES.ID1) INNER JOIN PROGRESS ON ACTIVITIES.ID3 = PROGRESS.ID3"
strSQL = strSQL & " WHERE ACTIVITIES.ID3 IN (" & Left(strIN, Len(strIN) - 1) & ")"

Trying to replace my one line/value with whatever is selected in List14.

'strSQL = strSQL & " WHERE ACTIVITIES.ID3=329;"

Can someone point me in the right direction?
 
Sorry this line should have been remed out
strWhere = " WHERE [ID3] in (" & Left(strIN, Len(strIN) - 1) & ")"

 
Replace this:
strIN = strIN & "'" & List14.Column(0, i) & "',"
with this ?
strIN = strIN & List14.Column(0, i) & ","

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Many thanks, that works now, very appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top