IIf

  • Thread starter Thread starter Bruce
  • Start date Start date
B

Bruce

I am trying to write into to a Field =IIf(
Code:
=2 Or 4,"Electronic","Form")
it won't quite work. Help!

Bruce
 
You must explicitly compare the field to each test value:

=IIf(
Code:
=2 Or [Code]=4,"Electronic","Form")
 
Thanks for your help, if I could ask another question.
=IIf(
Code:
=2,"Internet" Or [Code]=4,"ELS",Form")

Am I close?

Bruce

[QUOTE="Sandra Daigle"]
You must explicitly compare the field to each test value:

=IIf([Code]=2 Or [Code]=4,"Electronic","Form")

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

[QUOTE]
I am trying to write into to a Field =IIf([Code]=2 Or
4,"Electronic","Form") it won't quite work. Help!

Bruce[/QUOTE]
[/QUOTE]
 
Thanks for your help, if I could ask another question.
=IIf(
Code:
=2,"Internet" Or [Code]=4,"ELS",Form")

Am I close?[/QUOTE]

No.

IIF has three arguments:

A logical expression which evaluates to TRUE or FALSE (where FALSE is
defined as 0, TRUE as anything else)

A value to be returned if it's TRUE

A value to be returned if it's FALSE

You may want to use the Switch() function instead:

=Switch([Code] = 2, "Internet", [Code] = 4, "ELS", True, "Form")

Switch() takes arguments in pairs; the function goes through the
arguments two at a time, and when it first encounters a True
expression as the first of the pair, it returns the value of the
second argument of the pair.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top