IIf syntax issue

What is wrong with:

TotalHours1: IIf([NumberOfHours]="AE" Or "DC",0,[NumberOfHours])

--Steve
SteveL13Asked:
Who is Participating?
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor Infotrakker SoftwareCommented:
You can't use the OR operator like that.

You can do this:

TotalHours1: IIf([NumberOfHours]="AE" Or [NumberOfHours]="DC",0,[NumberOfHours])
0
 
SteveL13Author Commented:
Didn't work.  Says expression typed incorrectly.
0
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
you can also use this


TotalHours1: IIf([NumberOfHours] IN ("AE", "DC") ,0,[NumberOfHours])


is the field [NumberOfHours] TEXT data type?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
SteveL13Author Commented:
Also didn't work.  Says expression typed incorrectly.
0
 
SteveL13Author Commented:
NumberOfHours is number type
0
 
Rey Obrero (Capricorn1)Commented:
<NumberOfHours is number type >

then how come you are using the expression

IIf([NumberOfHours]="AE"

"AE"  is not NUMBER
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Are you sure NumberOfHours is correct name?

Not sure (I don't use IIF very much) but you may need to nest them:

IIf([NumberOfHours]="DC",0,IIf([NumberOfHours]="AE",0,[NumberOfHours]))
0
 
SteveL13Author Commented:
I am very sorry to both of you/  I have the wrong field name between the brackets.  Is ok now either way.
0
 
Rey Obrero (Capricorn1)Commented:
you need to change this field [NumberOfHours] with the field that contains the values  "AE", "DC"
0
All Courses

From novice to tech pro — start learning today.