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 / General 1 / February 2006

Tip: Looking for answers? Try searching our database.

IIF in Query Design

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bshort1023@yahoo.com - 28 Feb 2006 16:34 GMT
I created a query based on query.  I am creating a new field in the
query called "Series".  The field is created as follows:

Series: IIf([ITEM_NBR] Like "11-2*","11-2XX")

For all ITEM_NBR that are 11-201 or 11-202 etc make the value in the
Series field 11-2XX.  This works fine.  The problem is when I try to
add a 2nd part to this expression such as:

Series: IIf([ITEM_NBR] Like "11-2*","11-2XX") Or IIf([ITEM_NBR] Like
"11-3*","11-3XX")

This query runs but instead of putting a value of 11-2XX or 11-3XX in
the Series field I get a -1 for everything that should be 11-2XX or
11-3XX.

I have tried many different variations on this with no success.  Any
help would be greatly appreciated.

bshort1023
tina - 28 Feb 2006 16:43 GMT
try a nested IIf() function, as

Series: IIf([ITEM_NBR] Like "11-2*","11-2XX", IIf([ITEM_NBR] Like
"11-3*","11-3XX", Null))

it's a good idea to always include the "Else..." argument in the function,
which is why i added the "Null" value.

hth

> I created a query based on query.  I am creating a new field in the
> query called "Series".  The field is created as follows:
[quoted text clipped - 16 lines]
>
> bshort1023
james.igoe@gmail.com - 28 Feb 2006 16:51 GMT
Series: IIf([ITEM_NBR] Like "11-2*","11-2XX") Or IIf([ITEM_NBR] Like
"11-3*","11-3XX")

Your equation is incorrect.  Correctly, IIF is read left to right, so
it evaluates the statement, and if true it writes 11-2XX, else if next
is true it writes 11-3XX, else, [ITEM NBR], or whatever should be
written if the other two are false, e.g., "".

Series: IIf([ITEM_NBR] Like "11-2*","11-2XX",iIf([ITEM_NBR] Like
"11-3*","11-3XX",[ITEM_NBR]))

Pardon any inaccuracies in parsing, but this should be work.

James Igoe

james.igoe@gmail.com
Access/Excel VBA Developer
http://code.comparative-advantage.com/
 
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.