Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2005

Tip: Looking for answers? Try searching our database.

Compare 4 columns for equality

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jessica - 14 Nov 2005 15:01 GMT
I was wondering if there was any other way (other than IIF statement), to
check if the values in 4 specific columns are equal?  If I had 10 columns, an
IIF statement would be very lengthly.

E.g.         A        B
Name1  Jane   Jane
Name2  Jane   Jane
Name3  Jane   Jane
Name4  Bob    Jane

Name are the columns, A & B are the rows

A would return FALSE or No, B would return Yes or TRUE.

Thanks,
Jessica
John Spencer - 14 Nov 2005 15:55 GMT
IIF statement would probably be the simplest to implement AS LONG AS none of
the values was null.

IIF (A=B and B=C and C=D and D=E,True,False)

>I was wondering if there was any other way (other than IIF statement), to
> check if the values in 4 specific columns are equal?  If I had 10 columns,
[quoted text clipped - 13 lines]
> Thanks,
> Jessica
Jessica - 14 Nov 2005 17:26 GMT
Does anyone have any ideas, if there are nulls?

> IIF statement would probably be the simplest to implement AS LONG AS none of
> the values was null.
[quoted text clipped - 18 lines]
> > Thanks,
> > Jessica
John Spencer - 14 Nov 2005 17:43 GMT
If there are nulls, what results do you want?
A = "jessica"
B is Null
C = "Jessica"

Is this a match or not a match?  If the above case is not a match, then the
following should return what you want.  It will also return true if all the
fields are null.

IIF (Nz(A,"")=Nz(B,"") AND Nz(B,"")=Nz(C,""),True,False)

If you want to ignore null values in the comparison, then things get more
complicated and I would handle the whole thing with a custom function and
pass in an array of values and do the comparison there.  You need to state
your rules clearly.

-- All Nulls is a match (or not)
-- One or more nulls are ignored in the comparison
-- All non-null values must match (same as above)

> Does anyone have any ideas, if there are nulls?
>
[quoted text clipped - 23 lines]
>> > Thanks,
>> > Jessica
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.