R
ria
I am trying to use the multiple selections from a lift (in
a form) to query a table. I have written the code below
but, it only works for one selection. If I make more than
1 selection, the result is nothing. Does anyone have a
solution? The selction data I use is text. I am using the
data in Me!Text19 (control box) in the query.....
Private Sub List14_Exit(Cancel As Integer)
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set frm = Forms!DateRangeDialog
Set ctl = frm!List14
strSQL = ""
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & "\""" & ","
& "\"""
strSQL = Left$(strSQL, Len(strSQL) - 5) +
Mid$(strSQL, Len(strSQL) - 3, 2) + Right$(strSQL, 1)
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, (Len(strSQL) - 3))
Me!Text19 = strSQL
End Sub
Thank you
..
a form) to query a table. I have written the code below
but, it only works for one selection. If I make more than
1 selection, the result is nothing. Does anyone have a
solution? The selction data I use is text. I am using the
data in Me!Text19 (control box) in the query.....
Private Sub List14_Exit(Cancel As Integer)
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set frm = Forms!DateRangeDialog
Set ctl = frm!List14
strSQL = ""
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & "\""" & ","
& "\"""
strSQL = Left$(strSQL, Len(strSQL) - 5) +
Mid$(strSQL, Len(strSQL) - 3, 2) + Right$(strSQL, 1)
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, (Len(strSQL) - 3))
Me!Text19 = strSQL
End Sub
Thank you
..