Solved

Using Multiple criteria for iif Statemants

Posted on 2013-06-04
3
434 Views
Last Modified: 2013-06-05
This criteria is based on the production number so far if it is >=73 or if it is <=4 it uses the first code but all else uses  the second code. The problem I have is that I have over 300 production number that need the first code. but in the 300 some do not so Im having to go aaround and pick and choose numbers.

How do I put like for example 300-400 as a criteria and then drop down to 200-250 with out having to name each production number individually? This is what Im tring to do.

IIf([Production]>=73 Or [Production]<=4 or [Production]=300-322 or [Production]= 400-422
and on with out having to name each number invidually instead of sayin 400 , 401, 402 etc.

This code works fine but i need to add more criteria

IIf([Production]>=73 Or [Production]<=4,

(Abs(([F]![Induction]*4+[F]![Defuel]*1+[F]![TurretPull]*3+[F]![FuelCellRemoved]*5+[F]![BFCSProvision]*3+[F]![Err]*10+[F]![TASS]*16+[F]![BASSDProvision]*8+[F]![BASSDInstalled]*14+[F]![BFCSInstalled]*10+[F]![TurretInstalled]*4+[F]![E1Ground]*1+[F]![DriverSeatSpacer]*1+[F]![GunnersSeatStop]*1+[F]![AFESSwitchGuard]*1+[F]![ReliefHoleExtinguisher]*1+[F]![25mmHotBox]*2+[F]![ErrHandleMod]*0+[F]![FuelShutoffSleeve]*1+[F]![FinalQAQC]*8+[F]![Outduction]*6)/100)*100),

(Abs(([F]![Induction]*5+[F]![Defuel]*1+[F]![TurretPull]*10+[F]![FuelCellRemoved]*10+[F]![BFCSProvision]*5+[F]![Err]*10+[F]![TASS]*10+[F]![BASSDProvision]*0+[F]![BASSDInstalled]*0+[F]![BFCSInstalled]*10+[F]![TurretInstalled]*10+[F]![E1Ground]*1+[F]![DriverSeatSpacer]*0+[F]![GunnersSeatStop]*1+[F]![AFESSwitchGuard]*1+[F]![ReliefHoleExtinguisher]*1+[F ]![25mmHotBox]*2+[F]![ErrHandleMod]*0+[F]![FuelShutoffSleeve]*1+[F]![FinalQAQC]*12+[F]![Outduction]*10)/100)*100)) & "%" AS Percentages
FROM tblYakimaFullup


Should I go another route?
0
Comment
Question by:gigifarrow
3 Comments
 
LVL 9

Assisted Solution

by:armchair_scouse
armchair_scouse earned 166 total points
ID: 39218806
Gigi,

Looking at your criteria thus far:

[Production]>=73
[Production]<=4
[Production]=300-322
[Production]= 400-422

The last two criteria are already covered by the first criterion, because both 300-322 and 400-422 are greater than 73.

If you want to have specific production numbers that need to be included in your query, but the numbers are not sequential, e.g. 1,2,3,4,73,74,300,322, why not put the values in a 'SpecificProductionNumbers' table for example, and then update your query so that the table that has all of the other fields in your calculation (such as Induction, Defuel, etc.) links to the 'SpecificProductionNumbers' table by the Production field.  That way, you can add production numbers to the 'SpecificProductionNumbers' table and have them appear in your query which does all of the caculations.

It will also help simplify your IIF statement.
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 167 total points
ID: 39218916
I agree with armchair_scouse about your criteria >=73.  That needs to be changed if you want to select other ranges above 73.

Another possibility is to create a function such as this:
Private Function GetType(iProduction As Integer) As Byte
    Select Case iProduction
        Case 300 To 322, 370, 379, 400 To 422, Is < 4
            GetType = 1
        Case Is > 500
            GetType = 2
        Case Else
            GetType = 3
    End Select
End Function

Open in new window

Then you can use the Choose function in your query:
Choose(GetType([Production]), Formula1 goes here, Formula2 goes here, Formula3 goes here)
0
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 167 total points
ID: 39218985
If you need a range of numbers in a if statement, then just use "AND"

iif([Production]<=4 OR ( [Production] >= 300 AND [Production] <= 322 ) OR ( [Production] >= 400 AND [Production] <= 422)...


Also note, the extra parenthesis are not required above.  The order of operations will cause AND to be executed before OR so the statement executes the same with or without the parenthesis.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

831 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