updated hlp with multi-select query

  • Thread starter Thread starter ria
  • Start date Start date
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
..
 
Hi,


and if you comment the Left$, Mid$, Right$ formula, what do you got? It
seems you remove too many characters in that... studious... formula. (It
seems it removes the last two characters from ctl.ItemData(varItem), but in
a very complicated way to do it).


I assume the list box is a MultiSelect <> "None".




Hoping it may help,
Vanderghast, Access MVP
 
Back
Top