S
Steven M. Britton
I have an SQL query that just isn't working for me. Can
someone look at this and tell if you see anything I am
missing? What I am trying to do is have a query that can
run off of mulitiple selections from a listbox. My items
table has 6 columns: Record_Nbr, ID, ITEMCODE, ITEMQTY,
ITEMDESC, ITEMPRICE
The ID relates to my orders table... Here is the code I
could really use some help. Thanks.
Dim sInList As String
Dim vSelectedItem As Variant
' Populate sInList with a comma seperate list of values
For Each vSelectedItem In List246.ItemsSelected
sInList = sInList & List246.ItemData(vSelectedItem)
& ","
Next vSelectedItem
' Remove the trailing comma if it exists
If Len(sInList) > 1 Then
sInList = Left(sInList, Len(sInList) - 1)
End If
MsgBox sInList
' Change the SQL to use the IN list
CurrentDb.QueryDefs("qryItemsSelect").SQL = "SELECT *
FROM items WHERE items.ITEMCODE IN (" & sInList & ");"
MsgBox "Made it to Here"
DoCmd.OpenQuery ("qryItemsSelect"), acViewPreview, acEdit
The MsgBox sInList show all of the selections that I have
made, but I never get tot he MsgBox "Made it to Here". I
get an system error message that says: Item not found in
this collection.
-Steve
someone look at this and tell if you see anything I am
missing? What I am trying to do is have a query that can
run off of mulitiple selections from a listbox. My items
table has 6 columns: Record_Nbr, ID, ITEMCODE, ITEMQTY,
ITEMDESC, ITEMPRICE
The ID relates to my orders table... Here is the code I
could really use some help. Thanks.
Dim sInList As String
Dim vSelectedItem As Variant
' Populate sInList with a comma seperate list of values
For Each vSelectedItem In List246.ItemsSelected
sInList = sInList & List246.ItemData(vSelectedItem)
& ","
Next vSelectedItem
' Remove the trailing comma if it exists
If Len(sInList) > 1 Then
sInList = Left(sInList, Len(sInList) - 1)
End If
MsgBox sInList
' Change the SQL to use the IN list
CurrentDb.QueryDefs("qryItemsSelect").SQL = "SELECT *
FROM items WHERE items.ITEMCODE IN (" & sInList & ");"
MsgBox "Made it to Here"
DoCmd.OpenQuery ("qryItemsSelect"), acViewPreview, acEdit
The MsgBox sInList show all of the selections that I have
made, but I never get tot he MsgBox "Made it to Here". I
get an system error message that says: Item not found in
this collection.
-Steve