1

I'm having trouble getting this query to display any results.

SELECT Evaluation_Table.*
FROM Evaluation_Table
WHERE (Evaluation_Table.Test_ID 
In ([Forms]![Test Data]![Group_Test_IDs]));

The control, [Group_Test_IDs] is a textbox that contains a string of IDs. For example it just contains numbers separated by commas: 1,2,3,4,5. While debugging, If I changed the query to look like this, it properly returns records:

SELECT Evaluation_Table.*
FROM Evaluation_Table
WHERE (Evaluation_Table.Test_ID 
In (1,2,3,4,5));

I can't seem to find the proper syntax. SQL in Access can sometimes be weird.

1
  • 1
    you could try having them enter the IDs into a table instead of a textbox and then doing a join Commented Jun 25, 2015 at 16:53

1 Answer 1

2

I can't seem to find the proper syntax.

That's because there is none.

The IN selection cannot be dynamic; your only option is to rewrite the SQL via VBA.

Sign up to request clarification or add additional context in comments.

3 Comments

I just discovered the query will work if the textbox contains a single number. example: 3. So the control can be passed. The purpose of the IN clause is to be able to find records in a list. My syntax for the IN clause itself is correct. For some reason I'm unable to send multiple values separated by commas.
Well, that's exactly the issue. One value will do, a list will not. Neither will a function. You will have to write out the list and somehow insert or append it to the SQL without the list.
gotchya. I ended up working around this by using vb as you originally suggested. Thanks for the insight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.