Solved

Using Multiple criteria for iif Statemants

Posted on 2013-06-04
3
403 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

10 Experts available now in Live!

Get 1:1 Help Now