473,325 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Multiple criteria into one field in a query?

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.

8 3052
TheSmileyCoder
2,322 Expert Mod 2GB
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
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
32,556 Expert Mod 16PB
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
2,322 Expert Mod 2GB
WHERE [ID] In(100,135,206,310)
I did not know that...thanks...
Feb 5 '10 #5
NeoPa
32,556 Expert Mod 16PB
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
@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
@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
32,556 Expert Mod 16PB
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

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

Similar topics

1
by: KLAU | last post by:
I have a field that retrieves information from an expression in a query. I have used a DLookup function to get the calculated field from the query. However, the relationship is 1-to-many so one...
1
by: Steve | last post by:
I am using Access 2000 and I have a DB that is currently running four different queries from some Forms and subforms. These queries each have a date field that are seperate from each other that are...
6
by: Ralph2 | last post by:
Some time ago with a lot of help from this group I made a reasonably successful database to keep track of our shop drawings. However the searching mechanism is too complicated for the occasional...
3
by: tesc | last post by:
I am so aggravated and need any help I can get. I am using Access 2000 and am trying to sort multiple fields in a select query. My query is set up as follows: FIELD 1 FIELD 2 FIELD 3 ...
5
by: Beacher | last post by:
I've noticed that you can only have a sub datasheet pointing to one table... is there anyway to change this? for example I have Customer | ---------- Customer/Product | -----------...
0
by: Greg Strong | last post by:
Hello All, In the past I've used a combo box with the 'row source' being an Access SQL union query to select "All" or 1 for only 1 criteria in a query. An example is as follows: SELECT 0 As...
1
by: Ivan Carey | last post by:
How can a query display multiple fields with diferent condition on the same field example I have a field name of reason and a field name of duration. I would like to display 2 fileds of total...
2
by: fstenoughsnoopy | last post by:
I have a customer order database and I need to pull a customers information, ie first name, last name, address, city, state, zip, phone, etc, into the oder table. i don't know how to go about...
6
by: kcddoorman | last post by:
I built a select query filled with fields from multiple tables and queries. I have one field in this particluar query that will filter out a single order number. In the criteria box I put and that...
4
by: jvan2008 | last post by:
"Form1" combobox "cboModel" Row Source SELECT ., . FROM tblModel ORDER BY ; combobox "cboContactName" SELECT . FROM Query1 ORDER BY ;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.