Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using Multiple criteria for iif Statemants

Posted on 2013-06-04
3
Medium Priority
?
477 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 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

963 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