1. Registered User
Join Date
Jun 2013
Posts
8

Hi Guys,

I currently have the following,

IIf([Order type]="DIS" OR "203""P3", IIf([Order Type]="DIM" OR "202","P2", IIf([Order type]="DIU" OR "201","P1","0"))) AS Priority,

However it will only return P2 as an answer in all cases,

before it was strung out longer with a IIF stement for each order type but this returned nothing.

Many thanks

2. Registered User
Join Date
Jun 2013
Posts
8
Apoligies

"203","P3"

Although now it only returns P3

??

Join Date
Nov 2004
Location
out on a limb
Posts
13,692
try:-
Code:
`IIf([Order type] = "DIS" OR [Order type] = "203","P3", IIf([Order Type]="DIM" OR [Order type] = "202","P2", IIf([Order type] = "DIU" OR [Order type] = "201","P1","0"))) AS Priority`
in VB each element of an IF/IIF statement must be capable of evaluating to a boolean true false result.
so
Code:
`IIf([Order type]="DIS" OR "203"`
is going to cause problems

an IIF has 3 elements
IIF(boolean logic,value if true, value if false)
so from what you have above you have 3 tests
test 1:-
if the [Order type] is "DIS" OR "203" then use P3
otherwise
test 2:-
if the [Order Type = "DIM" OR "202" then use P2
otherwise
test 3 :-
if the [Order Type] = "DIU" OR "201" then use p1
Otherwise use 0.

however in VB/VBA you cannot use syntax sych as
Code:
`[Order Type] = "DIU" OR "201"`
instead you must specify the varaible being tested each time so use
Code:
`[Order Type] = "DIU" OR [Order Type] = "201"`

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•