N
nxqviet
Hi all,
I have a very simple question, but I just can't get it right after many
tries. I have this code, this is a part of a very long code that allow
you to select items from a list box and use them as a criteria for an
SQL statement.
This code uses the character in the list box rather than number ( i'm
refering to the Chr(34) portion of the two lines marked with stars). I
need to use number instead. I tried many time but can't get it rught.
Also, I do not fully understand this code, since it was developed with
a help of a friend of mine. Can someone explain for me what this line
do in the code? [strCriteria = Left(strCriteria, Len(strCriteria) -
3)]
---------------------------
If Me!lstList.ItemsSelected.Count > 0 Then
For Each varItem In Me!lstList.ItemsSelected
strCriteria = strCriteria & "tblTemp.ProductName = " & Chr(34) _
'*************
& Me!lstList.ItemData(varItem) & Chr(34) & "OR
" '*************
Next varItem
strCriteria = Left(strCriteria, Len(strCriteria) - 3)
Else
Msgbox "Must Select An Item From The List First"
Exit Sub
End If
I have a very simple question, but I just can't get it right after many
tries. I have this code, this is a part of a very long code that allow
you to select items from a list box and use them as a criteria for an
SQL statement.
This code uses the character in the list box rather than number ( i'm
refering to the Chr(34) portion of the two lines marked with stars). I
need to use number instead. I tried many time but can't get it rught.
Also, I do not fully understand this code, since it was developed with
a help of a friend of mine. Can someone explain for me what this line
do in the code? [strCriteria = Left(strCriteria, Len(strCriteria) -
3)]
---------------------------
If Me!lstList.ItemsSelected.Count > 0 Then
For Each varItem In Me!lstList.ItemsSelected
strCriteria = strCriteria & "tblTemp.ProductName = " & Chr(34) _
'*************
& Me!lstList.ItemData(varItem) & Chr(34) & "OR
" '*************
Next varItem
strCriteria = Left(strCriteria, Len(strCriteria) - 3)
Else
Msgbox "Must Select An Item From The List First"
Exit Sub
End If