Multiple IIf Statement in Expression

Drewster

New member
Local time
Today, 23:12
Joined
Sep 11, 2015
Messages
1
Hello All,

I have multiple IIf statements I wish to enter as an expression (back using access after a while) and return true or false.

IIf(
Code:
='12356' And [description] Like '*abc*',1,0)
IIf([Code]='78910' And [description] Like '*def*',1,0)
IIf([Code]='23456' And [description] Like '*ghi*',1,0)

Just how would you combined these (as in structure and can it be done).

Thanks Drew
 
Try this
=IIf(
Code:
='12356' And [description] Like '*abc*',1,
IIf([Code]='78910' And [description] Like '*def*',1,
IIf([Code]='23456' And [description] Like '*ghi*',1,0)))
 
Define 'multiple', is it just the 3 cases you posted or more? If its more, its time to move to a function. You pass the function the Code and description values, it does its logic and returns your result.

Also, your logic in the example could all be done with one IIf statement:

=IIf(
(
Code:
='123' AND [description]='abc') OR
([Code]='345' AND [description]='def') OR
([Code]='678' AND [description]='ghi')
, 1,0)

Even still, you should probably move to a function.
 

Users who are viewing this thread

Back
Top Bottom