OR works - AND gives zero result (1 Viewer)

maytaha

New member
Local time
Today, 11:09
Joined
Nov 12, 2012
Messages
9
Solved:OR works - AND gives zero result

I made a query that requires to enter two parameters (both are Number data type). I need the 2 parameters to be a criteria in the same row (AND). When I run the query it gives me zero result (and the data is already exists in the table). What is the mistake?:confused:
 
Last edited:

jdraw

Super Moderator
Staff member
Local time
Today, 04:09
Joined
Jan 23, 2006
Messages
15,393
Please show the code and a sample
 

maytaha

New member
Local time
Today, 11:09
Joined
Nov 12, 2012
Messages
9
SELECT Sanctions.ID, Sanctions.Emp_name, Sanctions.decision_num_s, Sanctions.decision_year_s, Sanctions.Sanction, Sanctions.Case_num_s, Sanctions.Case_year_s, Sanctions.Case_Side, Sanctions.Notes, Sanctions.Entry_date, Sanctions.Modif_date
FROM Sanctions
WHERE (((Sanctions.decision_num_s)=[enter decision number]) AND ((Sanctions.decision_year_s)=[enter decision year]));
 

Attachments

  • sanctions1.jpg
    sanctions1.jpg
    72.8 KB · Views: 54

maytaha

New member
Local time
Today, 11:09
Joined
Nov 12, 2012
Messages
9
when i enter 1 in [decision number] and 2014 in [decision year] it gives me zero results
 

Attachments

  • sanctions2.jpg
    sanctions2.jpg
    57.4 KB · Views: 53

GinaWhipp

AWF VIP
Local time
Today, 04:09
Joined
Jun 21, 2011
Messages
5,899
Does it give you the correct results if you just look up the Decision Number? In other remove the Year criteria and see if you can get it to work. If that works do the same thing with Year. My thought is it's not reading one of those fields correctly because what you have is correct.
 

maytaha

New member
Local time
Today, 11:09
Joined
Nov 12, 2012
Messages
9
YESS I removed year criteria and it worked.When I removed number criteria it didn't work. The reading problem was in the year. The problem that it was searching in the [id] field , not in [year] field
 

Attachments

  • Presentation1.jpg
    Presentation1.jpg
    98.1 KB · Views: 62

vbaInet

AWF VIP
Local time
Today, 09:09
Joined
Jan 22, 2010
Messages
26,374
If you're testing against one field it's OR.
If you're testing against two or more fields then AND.

Are you sure you don't want OR anyway?
 

GinaWhipp

AWF VIP
Local time
Today, 04:09
Joined
Jun 21, 2011
Messages
5,899
@vbaInet

AND is what is wanted but it wasn't pulling anything. I believe that was because the wrong field was being *read*. I think it's fixed now but waiting to hear back.
 

Brianwarnock

Retired
Local time
Today, 09:09
Joined
Jun 2, 2003
Messages
12,701
The SQL he posted does not match the Design Grid he later posted, which I think was after he fixed it following Gina's diagnostics suggestion.

Brian
 

vbaInet

AWF VIP
Local time
Today, 09:09
Joined
Jan 22, 2010
Messages
26,374
@vbaInet

AND is what is wanted but it wasn't pulling anything. I believe that was because the wrong field was being *read*. I think it's fixed now but waiting to hear back.
Je comprends!
 

Users who are viewing this thread

Top Bottom