Solved

IIf syntax issue

Posted on 2014-01-10
9
263 Views
Last Modified: 2014-01-10
What is wrong with:

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

--Steve
0
Comment
Question by:SteveL13
  • 4
  • 3
  • 2
9 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 250 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
 

Author Comment

by:SteveL13
ID: 39772394
Also didn't work.  Says expression typed incorrectly.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

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

Expert Comment

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

then how come you are using the expression

IIf([NumberOfHours]="AE"

"AE"  is not NUMBER
0
 
LVL 84
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 119

Expert Comment

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

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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 …

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now