Solved

IIf syntax issue

Posted on 2014-01-10
9
264 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 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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 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 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

832 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