By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Multiple criteria into one field in a query?

P: 12
In a MS Access query it's straight forward when you want to return record number 100 as in:
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM Depreciation
  3. WHERE (((Depreciation.ID)=300));
Is it possible, in this instance of the query, to ask for and return record number 100 and 135 and 206 and 310 and so on?

If the answer is "yes", how is it done?

dakota1606
Feb 4 '10 #1

✓ answered by NeoPa

A more flexible way would be something like :
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM   [Depreciation]
  3. WHERE  [ID] In(100,135,206,310)
@dakota1606
Not in this thread please. Ask a new question in a new thread. You may post a link to this one from there (or even vice-versa) if you think it would help.

Share this Question
Share on Google+
8 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
Yes
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM Depreciation
  3. WHERE (((Depreciation.ID)=300) OR ((Depreciation.ID)=213) OR ((Depreciation.ID)=217)));
Feb 4 '10 #2

P: 12
Excellent! That works great. Now all I have to do if figure out how to pass the criteria to the query from a control on a Form.

Any ideas?
Feb 5 '10 #3

NeoPa
Expert Mod 15k+
P: 31,263
A more flexible way would be something like :
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM   [Depreciation]
  3. WHERE  [ID] In(100,135,206,310)
@dakota1606
Not in this thread please. Ask a new question in a new thread. You may post a link to this one from there (or even vice-versa) if you think it would help.
Feb 5 '10 #4

TheSmileyCoder
Expert Mod 100+
P: 2,321
WHERE [ID] In(100,135,206,310)
I did not know that...thanks...
Feb 5 '10 #5

NeoPa
Expert Mod 15k+
P: 31,263
I sort of figured from your post Smiley ;)

That said, don't think you're the only one here learning things from other experts. I do it all the time. This is actually a great place for members and experts alike to pick up all sorts of tips and tricks.
Feb 5 '10 #6

P: 12
@NeoPa
TheSmileyOne's solution was workable but cumbersome for use on my form. But this....... this is awesome. I can make one entry or a dozen with no problem. Thanks huge!

dakota1606
Feb 8 '10 #7

P: 12
@TheSmileyOne
I appreciate your answer earlier. I just wanted you to know that your's worked, but NeoPa's answer is much more flexible and less cumbersome. This is a great learning place.

dakota160
Feb 8 '10 #8

NeoPa
Expert Mod 15k+
P: 31,263
I'm pleased you liked it :)

Other possibilities in SQL can be found in the Help. For this you need to navigate in Help for "Microsoft Jet SQL". It's hard to find without knowing where to look, but there's some good stuff in there if you can find it.
Feb 9 '10 #9

Post your reply

Sign in to post your reply or Sign up for a free account.