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 / April 2006

Tip: Looking for answers? Try searching our database.

How to exclude? or Include based on True/False

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul - 19 Apr 2006 04:34 GMT
I'm not sure how to go about doing what I need, so I defer to your expertise...

I have a table which I need to query  1)  [DestName]  or 2) [TransferedTo]
depending on the value of 3) [Transfered]

Can someone help me with the criteria for this. Exactly what I need is this:

If [Transfered] = True then I want [TransferedTo]. There will be a
[DestName] if [Transfered] is True, but I only want the value of
[TransferedTo].

If [Transfered] is False, then I want [DestName].

Any help is appreciated.
Paul - 19 Apr 2006 04:43 GMT
Forgot to add that [DesName] and [TransferedTo] are text fields while
[Transfered] is a Y/N field.

Cheers

> I'm not sure how to go about doing what I need, so I defer to your expertise...
>
[quoted text clipped - 10 lines]
>
> Any help is appreciated.
Saran - 19 Apr 2006 05:23 GMT
Paul,

    Below query might do what you expect.

Select iif(transfered,TransferedTo,DestName) from TableName

Regards,
Saran.
Paul B. - 19 Apr 2006 05:46 GMT
Saran,

Thanks, this works except now I have a bunch of blanks. Any idea how to get
rid of the blanks?

Cheers

> Paul,
>
[quoted text clipped - 4 lines]
> Regards,
> Saran.
Saran - 19 Apr 2006 06:51 GMT
Paul,

      Couple of ways to do this.

      1. Select iif(transfered,TransferedTo,DestName) as MyCol from
TableName Where not  iif(transfered,TransferedTo,DestName) is null

      2. Select * from (Select iif(transfered,TransferedTo,DestName)
as MyCol from TableName) TN Where not TN.Mycol is null

      Use whichever you feel perform better.

      Want to get rid of any other values? extend the WHERE condition.

Regards,
Saran.
Paul B. - 20 Apr 2006 16:13 GMT
Thanks Saran,

I couldn't get example 2 to work, but I did get the first one to work with
the inclusion of DISTINCT.

Thanks again for your help.

> Paul,
>
[quoted text clipped - 12 lines]
> Regards,
> Saran.
 
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.