Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using Multiple criteria for iif Statemants

Posted on 2013-06-04
3
Medium Priority
?
470 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Assisted Solution

by:armchair_scouse
armchair_scouse earned 664 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 668 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 668 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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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 …
Suggested Courses

722 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