Multiple IIf Statement in Expression (1 Viewer)

Drewster

New member
Local time
Today, 04:37
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
 

obeylele

Registered User.
Local time
Today, 08:37
Joined
Jul 29, 2005
Messages
28
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)))
 

plog

Banishment Pending
Local time
Yesterday, 23:37
Joined
May 11, 2011
Messages
11,613
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

Top Bottom