473,406 Members | 2,867 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,406 software developers and data experts.

Query using multiple criteria on one field

Hi everyone,

I am a beginning to intermediate user with Access 2000 on XP.

I am trying to create a query from a table of more than 1300 records. I need to look up individuals by their SSN only which is the primary key for the table) and I need to look up several at a time. Also, I will be looking up different individuals every time I run this query.

This is the SQL:

Expand|Select|Wrap|Line Numbers
  1. SELECT [Security Database].LastName, [Security Database].FirstName, [Security Database].SSN, [Security Database].DOB, [Security Database].POB, [Security Database].JobTitle, [Security Database].ClearanceLevel, [Security Database].DateGranted
  2. FROM [Security Database];
How I can I simply enter the required SSN's (which can be anywhere from 1 to 50 different ones at a time) under the criteria?

Please let me know in layman's terms since I am still learning.

I really, REALLY appreciate this and thank you in advance for ANY guidance....

Lisa
May 11 '07 #1
16 16600
puppydogbuddy
1,923 Expert 1GB
You need to create a search form that can handle multiple criteria. Fortunately, there is an example of one at the following link that you can download. The link contains detailed instructions, and hopefully be able to adapt to your application.

http://allenbrowne.com/ser-62.html
May 11 '07 #2
I checked out your link and it's more complicated than i can understand yet. I'm not looking up a range of SSN's but specific SSN's. Isn't there a way to put a parameter in that field Criteria stating to [Enter SSN] and then enter "123456789 and 987654321 and 555121212..." etc... for as many people as I need to find?
May 11 '07 #3
JConsulting
603 Expert 512MB
I checked out your link and it's more complicated than i can understand yet. I'm not looking up a range of SSN's but specific SSN's. Isn't there a way to put a parameter in that field Criteria stating to [Enter SSN] and then enter "123456789 and 987654321 and 555121212..." etc... for as many people as I need to find?
a quick easy way would be to create a table to put your ssn's

then in your query, you can use it

select * from table1 where ssn IN(Select ssn from ssntable)
May 11 '07 #4
Thank you! I didn't exactly do what you told me but I created a table for the SSN's and used that in a relationship with my full database for a query that I generate my report from.

By linking the SSN's for each table in that query I thought it would pull up only those SSN's that are listed SSN table. And it does but now there are blank places in my report; like the query isn't pulling over all of the information I requested from the database even though it's there and queried...

Just when I thought it was done... ARGH!
May 11 '07 #5
JConsulting
603 Expert 512MB
Thank you! I didn't exactly do what you told me but I created a table for the SSN's and used that in a relationship with my full database for a query that I generate my report from.

By linking the SSN's for each table in that query I thought it would pull up only those SSN's that are listed SSN table. And it does but now there are blank places in my report; like the query isn't pulling over all of the information I requested from the database even though it's there and queried...

Just when I thought it was done... ARGH!
can you post your SQL for your query? we'll get you sorted out.
J
May 11 '07 #6
SELECT [Security Database].LastName, [Security Database].FirstName, SSN.SSN, [Security Database].DOB, [Security Database].POB, [Security Database].JobTitle, [Security Database].ClearanceLevel, [Security Database].DateGranted
FROM [Security Database] INNER JOIN SSN ON [Security Database].SSN = SSN.SSN
ORDER BY [Security Database].LastName;


Thank you. I am actually leaving for the day and won't be able to respond until Monday.

You can see that I am trying to use the numbers from the SSN to pull the rest of the needed information from the database. I know the fields are filled in the database, so I don't know why the query is not populating fully. Some records do and some don't...

Thank you again.

Lisa
May 11 '07 #7
JConsulting
603 Expert 512MB
SELECT [Security Database].LastName, [Security Database].FirstName, SSN.SSN, [Security Database].DOB, [Security Database].POB, [Security Database].JobTitle, [Security Database].ClearanceLevel, [Security Database].DateGranted
FROM [Security Database] INNER JOIN SSN ON [Security Database].SSN = SSN.SSN
ORDER BY [Security Database].LastName;


Thank you. I am actually leaving for the day and won't be able to respond until Monday.

You can see that I am trying to use the numbers from the SSN to pull the rest of the needed information from the database. I know the fields are filled in the database, so I don't know why the query is not populating fully. Some records do and some don't...

Thank you again.

Lisa
Give this a shot
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. [Security Database].LastName, 
  3. [Security Database].FirstName, 
  4. [Security Database].SSN, 
  5. [Security Database].DOB, 
  6. [Security Database].POB, 
  7. [Security Database].JobTitle, 
  8. [Security Database].ClearanceLevel, 
  9. [Security Database].DateGranted
  10. FROM [Security Database]
  11. WHERE [Security Database].ssn IN(select ssn from ssn)
  12. ORDER BY [Security Database].LastName;
  13.  
May 11 '07 #8
Thank you. I did try it and it's still only pulling a few of the SSN's. I can't figure it out. The fields match, the SSN's are correct (I pulled them fro the regular DB). It's very random... I mean, it keeps showing the same 3 people but I can see no reason it would choose these 3 over the rest I had asked for... I double checked my input, making sure there were no typos, and everything meets up.

I just don't get it... COuld it be the primary key? If I delete some records and add new ones (SSN's in SSN, that is), would that cause a conflict?
May 14 '07 #9
JConsulting
603 Expert 512MB
Thank you. I did try it and it's still only pulling a few of the SSN's. I can't figure it out. The fields match, the SSN's are correct (I pulled them fro the regular DB). It's very random... I mean, it keeps showing the same 3 people but I can see no reason it would choose these 3 over the rest I had asked for... I double checked my input, making sure there were no typos, and everything meets up.

I just don't get it... COuld it be the primary key? If I delete some records and add new ones (SSN's in SSN, that is), would that cause a conflict?
ok, do it this way

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. [Security Database].LastName, 
  3. [Security Database].FirstName, 
  4. [Security Database].SSN, 
  5. [Security Database].DOB, 
  6. [Security Database].POB, 
  7. [Security Database].JobTitle, 
  8. [Security Database].ClearanceLevel, 
  9. [Security Database].DateGranted
  10. FROM [Security Database] Right Join SSN on [Security Database].SSN = SSN.SSN
  11. ORDER BY [Security Database].LastName;
  12.  
May 14 '07 #10
Nope... no go. Same 3 personnel only now with 8 empty records above them. I checked to see if perhaps I entered the numbers wrong. I looked in design view to see if the field info matched. And it all does....

I'm really sorry. I VERY much appreciate your help. Not sure what to do at this point other than delete all the queries and recreate them. Maybe there is a conflict I can't see somewhere. I'd like to send the table to you but it contains sensitive information. So I am limited in my way of obtaining help.

Lisa
May 14 '07 #11
JConsulting
603 Expert 512MB
Nope... no go. Same 3 personnel only now with 8 empty records above them. I checked to see if perhaps I entered the numbers wrong. I looked in design view to see if the field info matched. And it all does....

I'm really sorry. I VERY much appreciate your help. Not sure what to do at this point other than delete all the queries and recreate them. Maybe there is a conflict I can't see somewhere. I'd like to send the table to you but it contains sensitive information. So I am limited in my way of obtaining help.

Lisa
Hi Lisa,
What that SQL did was pull everything from the new table you made...the one you put SSNs into that you want to pull from your larger table. I have to ask at this point, since we're linking via the SSN itself...is there some kind of formatting difference. Are you masking the field in some way in your large table? You say the field is your Primary Index...is the field text or numeric? are there dashes in these? 123-22-2134 like that?
May 14 '07 #12
For tblSSN, the SSN is NOT the primary key - I am using autonumber for this table. The field is formatted to text, field size is 11 characters, the mask is 000\-00\-0000;0;_ and the caption is SSN.

for tblSecurity Database, the SSN IS the primary key and everything else formatted the same, text, 11 characters, caption, and input mask.

I double checked to make I entered the SSN's correctly on tblSSN and I did.

Also, if I haven't been clear. The only field in tbl SSN are the SSN's...

But since I now know what I need to do, I am am about to start over from scratch with fresh clean tables and queries and reports!

But I'll wait ot hear back from you! ;-p

Thank you again. You have been very helpful and wonderful in holding my hand through this!

Lisa
May 14 '07 #13
JConsulting
603 Expert 512MB
For tblSSN, the SSN is NOT the primary key - I am using autonumber for this table. The field is formatted to text, field size is 11 characters, the mask is 000\-00\-0000;0;_ and the caption is SSN.

for tblSecurity Database, the SSN IS the primary key and everything else formatted the same, text, 11 characters, caption, and input mask.

I double checked to make I entered the SSN's correctly on tblSSN and I did.

Also, if I haven't been clear. The only field in tbl SSN are the SSN's...

But since I now know what I need to do, I am am about to start over from scratch with fresh clean tables and queries and reports!

But I'll wait ot hear back from you! ;-p

Thank you again. You have been very helpful and wonderful in holding my hand through this!

Lisa
give this a try. It removes the - characters before it links. So we'll see

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. [Security Database].LastName, 
  3. [Security Database].FirstName, 
  4. [Security Database].SSN, 
  5. [Security Database].DOB, 
  6. [Security Database].POB, 
  7. [Security Database].JobTitle, 
  8. [Security Database].ClearanceLevel, 
  9. [Security Database].DateGranted
  10. FROM [Security Database] Right Join SSN on replace([Security Database].SSN,"-","") = replace(SSN.SSN,"-","")
  11. ORDER BY [Security Database].LastName;
  12.  
May 14 '07 #14
Woo Hoo! Making progress! It pulled 9 out of 12 listed with 3 blank record at the top of the answer table.

I created that mask so I could just enter 123456789 and it would appear 123-45-6789. Is that the issue?
May 14 '07 #15
JConsulting
603 Expert 512MB
Woo Hoo! Making progress! It pulled 9 out of 12 listed with 3 blank record at the top of the answer table.

I created that mask so I could just enter 123456789 and it would appear 123-45-6789. Is that the issue?
Seems so. I am not sure why you have blank lines though, unless you have blanks in your SSN table. There may also be null SSNs in your big table too...so check for that. If there are, you probably want to ignore those?
May 14 '07 #16
I'll have to check that out further and let you know.

But in the mean time... THANK YOU!!!!! You have been a tremendous help! I will let you know what happens!

You rock!

Lisa
May 14 '07 #17

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...
3
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
6
by: Andy | last post by:
Hello, I am having many problems with setting up a parameter query that searches by the criteria entered or returns all records if nothing is entered. I have designed an unbound form with 3...
1
by: Robert | last post by:
I am trying to create a db for service providers by county. I'm relatively new to db programming, but I have done quite a bit of programming ranging from the old basic days up to doing some...
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...
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
3
by: sar68 | last post by:
I'm using Access 2007 on windows vista. Intel T7400 with 2.16 GHz and 2 gigs of ram. 64 bit os. If I run a query that goes across multiple tables, I get sensible results. However, if I run a...
4
by: dizzydangler | last post by:
Hi all, I am a new Access user and just starting to get my head around some of the basic concepts, so please take it easy on me :) My company has been managing client records on excel, and I’m in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.