Filter Combo Box by Form Using In()

TimTDP

Registered User.
Local time
Today, 19:51
Joined
Oct 24, 2008
Messages
213
I want to filter the records in a combo box (cboSupplier) using the In() function.

On the form I have an unbound control called "intFilter". It contains the following string: 23, 58

The SQL statement for the combo box is
Code:
SELECT SupplierID, SupplierName
FROM tblSupplier
ORDER BY SupplierName;
In the criteria for field SupplierId I want to use the In() function so that the only records returned by the combo box are those in "intFilter"
I have tried
Code:
 In (Forms![frmSupplierReport]![intFilter]
but this does not work.

If I put: In (23, 58) in the criteria it works, but I cannot hard code it because the string in "intFilter" will change on the fly!

How would I achieve this?
 
Try

" IN (" & Forms!frmSupplierReport!intFilter & ")"
 
Get error that expression is typed incorrectly or too complex to be evaluated
 
Question, if you are using just 1 field to filter then why use IN()?
Just type Forms!frmSupplierRepoet!intFilter in the field that holds the data.

I am reading your post as there is 1 field that holds the data, Correct.
23, 58

If this is not true and the data is in 2 fields then IN() will not work.

SELECT * FROM Customers
WHERE City IN ('Paris','London')

In will select a City from Either of the 2 not select both.

Dale

http://www.w3schools.com/sql/sql_in.asp
 
Question, if you are using just 1 field to filter then why use IN()?
Just type Forms!frmSupplierRepoet!intFilter in the field that holds the data.

I am reading your post as there is 1 field that holds the data, Correct.
23, 58
Forms!frmSupplierRepoet!intFilter should work, but I am concerned about the order of the data. 23, 58 will work, but 58, 23 will not!
This is why I want to use In()
 

Users who are viewing this thread

Back
Top Bottom