can I put "two statement" in a IIF statement?

  • Thread starter Thread starter cdolphin88
  • Start date Start date
C

cdolphin88

Hi,

Is that possible to put "two statement" in a IIF statement?

I want to put IIF(q6a = 0, 'yes' AND q6c = 'N/A') like this?

In my table, the q6a and q6c has values 0 or 1.

0 means YES or N/A
1 means NO


Cheers!


Claudi
 
something = IIF( test , answer if test is true, answer if test is
false )

the test can be simple, as in q6a = 0
or more complex as in:
(q6a=0) AND (q6c = 'N/A')

The answer can be a constant, or a field, or something that returns an
answer, like a query or a function, such as another IIF statement.

You can put lots of statements in an IIF statement, but the syntax must be
right.
 
You can, but you are mixing data types. If the possible values are 0 and 1,
testing for 'yes' or 'N/A' will not work at all. If you have fields like
this that are purely binary, then you should be using a Boolean data type for
your fields. A Boolean data type will store only two values, 0 (False) and
-1 (True). Then you code could look like this:

IIF(q6a AND q6c, ReturnValueForTrue, ReturnValueForFalse)
or
IIF(q6a =True AND q6c = True, ReturnValueForTrue, ReturnValueForFalse)
If you want to keep the upside down confusing 0 = yes and 1 = no then the
code would be

IIF(q6a = 0 AND q6c = 0, ReturnValueForTrue, ReturnValueForFalse)

or
IIF(q6a + q6c = 0, ReturnValueForTrue, ReturnValueForFalse)
 
Back
Top