Link to home
Start Free TrialLog in
Avatar of eshurak
eshurakFlag for United States of America

asked on

query to test if fields have the same value

Hello Experts,

I'm try to create a calculated field in a query that tests if three fields have the same value in the same records and I'm stumped.

I'm using Access 2010

Thanks
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Why not do that in the WHERE clause instead ?

mx
Example:

SELECT Table1.*
FROM Table1
WHERE (((Table1.FIELD1)="abc") AND ((Table1.FIELD2)="abc") AND ((Table1.FIELD3)="abc"));

If not, what do you have so far?

mx
Avatar of eshurak

ASKER

The values will never be the same.

Also It needs to be a calculated field.  Something like:
Expr1: ([fld_2007]=[fld_2008])=([fld_2007]=[fld_2009])=([fld_2008]=[fld_2009])
Not following:

"that tests if three fields have the same value "

"The values will never be the same."

?
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eshurak

ASKER

Let me clarify:  the value we are looking for will never be the same.  In other words we can't test for "ABC" like you did in your second post.  The values in my fields could be any numeric combination (it is a text field as there can be leading zeros).
Avatar of eshurak

ASKER

That works.  I shortened it to:

=[fld_2008]) And ([fld_2007]=[fld_2009]) And ([fld_2008]=[fld_2009])

Thanks