Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

IIf syntax issue

Posted on 2014-01-10
9
Medium Priority
?
275 Views
Last Modified: 2014-01-10
What is wrong with:

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

--Steve
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1000 total points
ID: 39772362
You can't use the OR operator like that.

You can do this:

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

Author Comment

by:SteveL13
ID: 39772384
Didn't work.  Says expression typed incorrectly.
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 39772385
you can also use this


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


is the field [NumberOfHours] TEXT data type?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:SteveL13
ID: 39772394
Also didn't work.  Says expression typed incorrectly.
0
 

Author Comment

by:SteveL13
ID: 39772396
NumberOfHours is number type
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39772401
<NumberOfHours is number type >

then how come you are using the expression

IIf([NumberOfHours]="AE"

"AE"  is not NUMBER
0
 
LVL 85
ID: 39772405
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
 

Author Comment

by:SteveL13
ID: 39772408
I am very sorry to both of you/  I have the wrong field name between the brackets.  Is ok now either way.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39772409
you need to change this field [NumberOfHours] with the field that contains the values  "AE", "DC"
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question