Sure -- depending upon the data type of the values. Not is a negation
operator, meaning it turns True into False, or False into True. The not
equals operator (<>) is a comparison operator, and does not change a value
at all.
>> Can there ever be a difference between results produced by <> and those
>> produced by not whenever they can be used in the same place in a query
> Sure -- depending upon the data type of the values. Not is a negation
> operator, meaning it turns True into False, or False into True. The not
> equals operator (<>) is a comparison operator, and does not change a value
> at all.
Can't really think how <> and NOT are interchangable, unless he is asking if
'NOT(a=b) is the same as (a<>b)?
Those 2 are logically equivilent and will always produce the same result.
Neeraj: Are you asking this due to a specific problem you have, or just
general interest?
neeraj - 03 Nov 2005 17:36 GMT
I am not asking due to a specific problem but out of general interest. I have
been using both not and <> in the criteria row of the design grid of my
queries interchangeably as it has always yielded same results. I was curious
exactly because of this reason: if they have been yielding same results, was
that just because of the specific data sets that I have dealt with or could I
ever encounter a case where results would be different with <> and "not" and
my results would be erroneous because I chose the wrong one randomly.
Ken has written that the difference will depend upon the data type of
values. How does data type affect the difference in results of not and <> ?
To take a simple example, say there is a table Months with 2 fields: Month
and Month Number with these values:
Month Number Month
1 January
2 February
....
12 December
I have the following 2 queries one with <> and the other with "not"
Query1:
SELECT Months.Month, Months.[Month Number]
FROM Months
WHERE (((Months.[Month Number])<>"1"));
Query2:
SELECT Months.Month, Months.[Month Number]
FROM Months
WHERE ((Not (Months.[Month Number])="1"));
Both queries produce the same results that is all months except January. I
have always found the results to be the same using <> and not in the above
way.
Can the results ever be different using <> and not in this way and if yes,
what would that case be? Thanks.
> >> Can there ever be a difference between results produced by <> and those
> >> produced by not whenever they can be used in the same place in a query
[quoted text clipped - 10 lines]
> Neeraj: Are you asking this due to a specific problem you have, or just
> general interest?
Ken Snell [MVP] - 03 Nov 2005 23:07 GMT
Ahhh... the situation you show is one where Not will work the way you want.
That is because this statement:
Months.[Month Number]<>"1"
produces a True or False result. The field either equals "1" or it doesn't.
Putting Not in front of it changes it from True to False or vice versa.

Signature
Ken Snell
<MS ACCESS MVP>
>I am not asking due to a specific problem but out of general interest. I
>have
[quoted text clipped - 52 lines]
>> Neeraj: Are you asking this due to a specific problem you have, or just
>> general interest?
Ken Snell [MVP] - 04 Nov 2005 01:55 GMT
>>> Can there ever be a difference between results produced by <> and those
>>> produced by not whenever they can be used in the same place in a query
[quoted text clipped - 7 lines]
> if 'NOT(a=b) is the same as (a<>b)?
> Those 2 are logically equivilent and will always produce the same result.
My thinking was this:
Not True
vs.
<> True

Signature
Ken Snell
<MS ACCESS MVP>