How to make a iiF statement work based on a criteria being not null.

Posted on 2013-06-05
Last Modified: 2013-06-21
Okay this query does things based on production number and the fields are check mark.

I need to add a criteria to all of this. which do not calculate fields unless in shop date is not null.  The code below works fine.

I tried WHERE ((Not (tblTempleFacilityFullup.InShopDate) Is Null)

SELECT F.Production, F.InShopDate, F.SerialNumber, F.Unit, F.Location, F.Induction, F.TearDown, F.Provision, F.E1GroundInsert, F.ReliefHoleExtinguisher, F.AssemblyA, F.FuelShotOffSleeve, F.AsemblyB, F.CEPUpgrade, F.AFESCEPSwitch, F.AssemblyC, F.ERRHandle, F.DriverSeat, F.AssemblyD, F.HotBoxEnhanceMent, F.AssemblyE, F.LegacyBattery, F.[LED/ERR], F.T161Track, F.AFES, F.HotBox, F.BASSM2, F.GunnersSeatStopRework, F.RoadTest, F.QC, F.OutDuction, F.DateCompleted, F.DateReturned, F.Remarks, F.FeriteBead, F.HotBox57K6608, F.AOA, F.BRATP, F.RollerHousingMOD, IIf([Production]=343-346 Or [Production]=347-374 Or [Production]=378 Or [Production]=379-380 Or [Production]=391-403 Or [Production]=405-407 Or [Production]=409-410 Or [Production]=412-422 Or [Production]=424-428 Or [Production]=432-464 Or [Production]=467 Or [Production]=469 Or [Production]=471-507 Or [Production]=524-536,Format(Abs(([F]![Induction]*6+[F]![TearDown]*10+[F]![Provision]*10+[F]![AssemblyA]*10+[F]![AsemblyB]*10+[F]![AssemblyC]*10+[F]![AssemblyD]*10+[F]![AssemblyE]*10+[F]![RoadTest]*4+[F]![QC]*10+[F]![OutDuction]*10)/100),"00.0%"),Format(Abs(([F]![Induction]*5+[F]![TearDown]*10+[F]![Provision]*0+[F]![AssemblyA]*20+[F]![AsemblyB]*0+[F]![AssemblyC]*0+[F]![AssemblyD]*20+[F]![AssemblyE]*25+[F]![RoadTest]*0+[F]![QC]*10+[F]![OutDuction]*10)/100),"00.0%")) AS Percentages
FROM tblTempleFacilityFullup AS F;
Question by:gigifarrow
LVL 92

Accepted Solution

Patrick Matthews earned 250 total points
ID: 39223785
To test for (not null) in the WHERE clause:

WHERE SomeColumn Is Not Null

To test in an IIf():

IIF(SomeColumn Is Not Null, "Not Null", "Null")
LVL 12

Assisted Solution

pdebaets earned 250 total points
ID: 39223923
You've got a big IIF statement in there that starts out like this:

IIf([Production]=343-346 Or [Production]=347-374 ...

I think that will be a problem because you don't have quotes around the "343-346". Access may treat that as a subtraction so [Production]= 343-346 might be equivalent to [Production] = -3. I don't think you want that. If [Production] is a text field, then try [Production] = "343-346". Or even better, try

IIf([Production] IN ("343-346", "347-374", "378", "379-380", ...), <true part>, <false part>)

... where "..." means put the rest of your list of production numbers in there.

Author Comment

ID: 39225276
That is not correct this is not the same question. It is the same code but I am trying to add another criteria to it . Please read the other question throughly. This question should not be deleted.

The code works fine. Im trying to add :

WHERE ((Not (tblTempleFacilityFullup.InShopDate) Is Null)

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 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

18 Experts available now in Live!

Get 1:1 Help Now