What's wrong with this IIf expression

B

betan

I want the expression to show "BI" from all values start from BI**** BUt it
doesnt work. I am using * as wildcare:

IIf([Subject]=BI*, "BI") and this too: IIf([Subject]=*F1*, "F1")

Is BI* valid value? (in Subject field I have BIF1A, BIF3B & etc)

What is worng ?
Pls help. Thank you
 
J

Jerry Whittle

IIf(expr, truepart, falsepart)

You need to put in a falsepart if it isn't BI*. Then there is the problem of
the wildcard. Try this instead.

IIf(Left([Subject],2)= "BI", "BI", [Subject])
 
M

Marshall Barton

betan said:
I want the expression to show "BI" from all values start from BI**** BUt it
doesnt work. I am using * as wildcare:

IIf([Subject]=BI*, "BI") and this too: IIf([Subject]=*F1*, "F1")

Is BI* valid value? (in Subject field I have BIF1A, BIF3B & etc)


You must use the Like operator with wildcards. Also, the
pattern must be enclosed in quotes:

IIf([Subject] Like "BI*", "BI")
 
B

betan

Thanks Jerry for the help

Jerry Whittle said:
IIf(expr, truepart, falsepart)

You need to put in a falsepart if it isn't BI*. Then there is the problem of
the wildcard. Try this instead.

IIf(Left([Subject],2)= "BI", "BI", [Subject])
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

betan said:
I want the expression to show "BI" from all values start from BI**** BUt it
doesnt work. I am using * as wildcare:

IIf([Subject]=BI*, "BI") and this too: IIf([Subject]=*F1*, "F1")

Is BI* valid value? (in Subject field I have BIF1A, BIF3B & etc)

What is worng ?
Pls help. Thank you
 
B

betan

Thanks Barton for the help

Marshall Barton said:
betan said:
I want the expression to show "BI" from all values start from BI**** BUt it
doesnt work. I am using * as wildcare:

IIf([Subject]=BI*, "BI") and this too: IIf([Subject]=*F1*, "F1")

Is BI* valid value? (in Subject field I have BIF1A, BIF3B & etc)


You must use the Like operator with wildcards. Also, the
pattern must be enclosed in quotes:

IIf([Subject] Like "BI*", "BI")
 
Top