subquery with value from a form

  • Thread starter Thread starter MSD
  • Start date Start date
M

MSD

My query works when I use fixed values. However, when I use values from a
form, it doesn't work.

This is the difference in the saved query's SQL statement -

This one works:
SELECT ItemName, ItemNo
FROM tblItems
WHERE (ItemNo In (200,250,333));

This one doesn't work:
SELECT ItemName, ItemNo
FROM tblItems
WHERE (ItemNo In ([Forms]![myForm]![myText]));

myText contains comma separated values, such as: 100,200,300

My form contains a command button that opens the query after values are
entered in the text box.

Thanks very much,

Emma
 
Hi,


Try:

... WHERE ( "," & Forms!myForm!myText & "," ) LIKE ( "*," &
ItemNo & ",*" )


assuming that in myText, you have 100,200,300 and not "100, 200, 300"
(ie, no space after the coma).


Hoping it may help,
Vanderghast, Access MVP
 
Back
Top