IIF statement

K

Karen

I would like to use an IIF statement to look for the text in field [Type] and
if it is not Voluntary, to show Employer on the report.

I have tried IIF([Type] Not Like "Voluntary","Employer","Voluntary") and all
I get is Employer listed on the report. It changes those that are voluntary
to employer.

Not sure what I am doing incorrectly.
 
J

Jeff Boyce

Karen

Check Access HELP on "Like".

Your IIF() expression tells Access to look for EXACTLY "Voluntary" in the
[Type] field. If you meant "Voluntary" SOMEWHERE IN the [Type] field, you'd
need to use something more like:

IIF(InStr([Type],"Voluntary")>0,"Voluntary","Employer")

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
K

Karen

Thanks for the quick response.

The field contains the value "Voluntary" along with other values. I want
all those values that are not "Voluntary" to show "Employer" on the report.
I have tried several different IIF, but always report shows "Employer" even
when the value is "Voluntary".

Jeff Boyce said:
Karen

Check Access HELP on "Like".

Your IIF() expression tells Access to look for EXACTLY "Voluntary" in the
[Type] field. If you meant "Voluntary" SOMEWHERE IN the [Type] field, you'd
need to use something more like:

IIF(InStr([Type],"Voluntary")>0,"Voluntary","Employer")

Regards

Jeff Boyce
Microsoft Office/Access MVP

Karen said:
I would like to use an IIF statement to look for the text in field [Type]
and
if it is not Voluntary, to show Employer on the report.

I have tried IIF([Type] Not Like "Voluntary","Employer","Voluntary") and
all
I get is Employer listed on the report. It changes those that are
voluntary
to employer.

Not sure what I am doing incorrectly.
 
J

Jeff Boyce

Have you tried the alternate expression I provided?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Karen said:
Thanks for the quick response.

The field contains the value "Voluntary" along with other values. I want
all those values that are not "Voluntary" to show "Employer" on the
report.
I have tried several different IIF, but always report shows "Employer"
even
when the value is "Voluntary".

Jeff Boyce said:
Karen

Check Access HELP on "Like".

Your IIF() expression tells Access to look for EXACTLY "Voluntary" in the
[Type] field. If you meant "Voluntary" SOMEWHERE IN the [Type] field,
you'd
need to use something more like:

IIF(InStr([Type],"Voluntary")>0,"Voluntary","Employer")

Regards

Jeff Boyce
Microsoft Office/Access MVP

Karen said:
I would like to use an IIF statement to look for the text in field
[Type]
and
if it is not Voluntary, to show Employer on the report.

I have tried IIF([Type] Not Like "Voluntary","Employer","Voluntary")
and
all
I get is Employer listed on the report. It changes those that are
voluntary
to employer.

Not sure what I am doing incorrectly.
 
J

Jeff Boyce

The next thing I would try is to return the value of
Instr([Type],"Voluntary">0). I'm guessing that these are ALL False.

This could happen if the underlying field in the table is defined as a
"Lookup" field, storing the ID value, but displaying things like
"Voluntary"?! Check the table definition...

Regards

Jeff Boyce
Microsoft Office/Access MVP

Karen said:
Yes, it did not work. All the values returned are "Employer", even though
some should be "Voluntary".

Jeff Boyce said:
Have you tried the alternate expression I provided?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Karen said:
Thanks for the quick response.

The field contains the value "Voluntary" along with other values. I
want
all those values that are not "Voluntary" to show "Employer" on the
report.
I have tried several different IIF, but always report shows "Employer"
even
when the value is "Voluntary".

:

Karen

Check Access HELP on "Like".

Your IIF() expression tells Access to look for EXACTLY "Voluntary" in
the
[Type] field. If you meant "Voluntary" SOMEWHERE IN the [Type] field,
you'd
need to use something more like:

IIF(InStr([Type],"Voluntary")>0,"Voluntary","Employer")

Regards

Jeff Boyce
Microsoft Office/Access MVP

I would like to use an IIF statement to look for the text in field
[Type]
and
if it is not Voluntary, to show Employer on the report.

I have tried IIF([Type] Not Like "Voluntary","Employer","Voluntary")
and
all
I get is Employer listed on the report. It changes those that are
voluntary
to employer.

Not sure what I am doing incorrectly.
 

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