Solved

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

Posted on 2013-06-05
4
396 Views
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;
0
Comment
Question by:gigifarrow
4 Comments
 
LVL 92

Accepted Solution

by:
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")
0
 
LVL 12

Assisted Solution

by:pdebaets
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.
0
 

Author Comment

by:gigifarrow
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)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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 …
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now