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 2008

Tip: Looking for answers? Try searching our database.

Using Or with an IIf Statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dbad7 - 22 Apr 2008 00:58 GMT
I am having trouble using an IIf statement as criteria. It seems simple
enough but does not work. I am using a Combo box to narrow down the condtion
of inventory. My combo box is simple: Good, Bad, All

HAVING
[CONDITION_NAME]=IIf([Forms]![frmMainNew]![cboCondInv]="Good",("Repaired" Or
"New"),IIf([Forms]![frmMainNew]![cboCondInv]="Bad","Defective" Or "BER" Or
"IN-Warranty" Or "To-Outsource",Like "*"))

Access is not letting me use Or in the Then clause, saying it's too
complicated. Is there another way to do this?
Marshall Barton - 22 Apr 2008 01:36 GMT
>I am having trouble using an IIf statement as criteria. It seems simple
>enough but does not work. I am using a Combo box to narrow down the condtion
[quoted text clipped - 7 lines]
>Access is not letting me use Or in the Then clause, saying it's too
>complicated. Is there another way to do this?

You can not include parts of an expression inside an IIf.
Each part of an And/Or must be a complete comparison.

I think this should do what you want.  Note that I used two
different way to deal with an OR kind of situation to
provide examples.

IIf(Forms!frmMainNew!cboCondInv] = "Good", CONDITION_NAME =
"Repaired" Or CONDITION_NAME = "New",
IIf(Forms!frmMainNew!cboCondInv = "Bad", CONDITION_NAME
IN("Defective","BER","BER","IN-Warranty","To-Outsource"),
True)

Signature

Marsh
MVP [MS Access]

 
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



©2009 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.