Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple IIf function in design view

Status
Not open for further replies.

2Plan

MIS
Mar 29, 2005
55
0
0
US
I would like to create a make-table that uses a multiple IIf function similar to the statement below:

DivAbr: IIf([BLOCKNAME]="640-10","UTFRI",[DIVISIONABBR])

Based on the 8 different [BLOCKNAME], I want the [DIVISIONABBR] to say "UTFRI".

It works for one condition, but not for several. Does anyone know how to get this to work?

Thanks
 
I think I would simply build a small table

tblBlockNames
strName

In this table put your 8 names: "640-10"

Now left join your table to tblBlockNames and include strName in the query. The ones that do not "link" will be null

iff(isnull([strName]),[DivisionABBR],"UTFRI")

Makes it easy to change or add more without changing the sql.
 
FYI: multiple [tt]IIf[/tt]'s = [tt]Switch()[/tt] function.
 
What would the syntax of the Switch function look like with a couple of block names in the example below?

DivAbr: IIf([BLOCKNAME]="640-10","UTFRI",[DIVISIONABBR])

Thanks.
 
The last argument is your catch all, just needs to be any expression that evaluates True (since False = 0 you should be able to use any other integer, positive or negative.)
[tt]DivAbr: SWITCH(([BLOCKNAME]="640-10", "UTFRI", [BLOCKNAME]="740-10", "Something", [BLOCKNAME]="840-10", "SomethingElse", 1=1, [DIVISIONABBR])[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top