IIF Statement in Query

M

MBurns

I have two fields in a database "Insurance In - Yes" and "Insurance In - No"
and they are check boxes. I am creating a query to export and I want a field
that says Insurance In to show Yes if the Yes box is checked and No if the
other is checked or Null if neither one is checked. How do I create the IIF
statement in the query?
 
K

KARL DEWEY

In design view --
Insurance: IIF([Insurance In - Yes] = -1, "Yes", IIF([Insurance In - No]
= -1, "No", "Error"))
In SQL view --
...., IIF([Insurance In - Yes] = -1, "Yes", IIF([Insurance In - No] = -1,
"No", "Error")) AS Insurance, ...

You should have only one field and make the display a Yes/No display. Or
you could have an option group so that 0- Unknown, 1- Yes, 3- No are
selection options. then use a nested IIF statement to display text.
 
F

fredg

I have two fields in a database "Insurance In - Yes" and "Insurance In - No"
and they are check boxes. I am creating a query to export and I want a field
that says Insurance In to show Yes if the Yes box is checked and No if the
other is checked or Null if neither one is checked. How do I create the IIF
statement in the query?

i don't quite understand your database structure.
Why do you need two separate check box fields for [Insurance In - Yes]
and [Insurance in - No]?
One field, [InsuranceIn], is all you need.
Either the [InsuranceIn] field is checked (yes) or it's not checked
(no).

One way to display the word "Yes" if a field is checked (or "No" if
not checked) is:

NewColumn:IIf([InsuranceIn] = -1,"Yes","No")

Export the NewColumn field instead of [Insurance In] field.
 

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

Top