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

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
 
D

David Cox

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.
 
K

Klatuu

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top