Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
frm1868
Starting Member
2 Posts |
Posted - 2003-11-14 : 06:51:46
|
I want to use the IN statement in a Query whereas the parameters are from a form. The statement looks like:WHERE ProductRange IN (Forms!Product!Range)The product range will be selected in a form and might have up to 7 values. The query does only work when 1 value as range has been selected. With more than 1 it doesn't work. The range field is of the type string.Anybody can heelp me? Thanks! |
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-11-14 : 07:29:06
|
What is the Range control? A listbox or what? |
 |
|
frm1868
Starting Member
2 Posts |
Posted - 2003-11-14 : 08:54:13
|
In the database range is of the type string.The form is used for reports. A product belongs to a range, the application knows in total 7 ranges. In the form exists a group of 7 control boxes for the range. Each control box represents a range. The report lists all products with the selected range in the form. |
 |
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-11-14 : 09:21:45
|
If you are sure that Forms!Product!Range contains severalconcatenated ProductRanges then you can use the following:.. .. WHERE InStr(Forms!Product!Range, ProductRange) > 0 |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-11-14 : 09:30:57
|
instead of trying to run some sql, just saydebug.print Forms!Product!Rangeor something like that. Look at the contents of your control and see if it makes sense that it would work the way you hope. Most "range" or multiselect controls return arrays or collections of what is selected so you would need to enumerate those lists and build your own comma-seperated string. Or better yet, fill up a table with what is selected and instead of a "WHERE IN()" you would use a JOIN. (though beware of concurrent user issues with that techinque).- Jeff |
 |
|
|
|
|