VBBRett
asked on
I have a new query expression that I need to be done
I have an IIf statement that I am trying to do. My expression that I am trying to do is if the DED Code is equal to TXFE or
IIf((AllEmployeeSumoftaxab lewages.[D ED Code] = 'TXFE' or (AllEmployeeSumoftaxablewa ges.[DED Code] = 'TXUN'),[LimitTaxableWages ] = 28900,0) as LimitTaxableWages
I get a syntax error in my SQL statement and LimitTaxableWages is a new field I am trying to create in this query. Please let me know. Thanks!
IIf((AllEmployeeSumoftaxab
I get a syntax error in my SQL statement and LimitTaxableWages is a new field I am trying to create in this query. Please let me know. Thanks!
ASKER
I have a syntax error with a comma somewhere. Here is my complete query with your expression at the bottom:
SELECT AllEmployeeSumoftaxablewag es.[Record Type], AllEmployeeSumoftaxablewag es.Company , AllEmployeeSumoftaxablewag es.Employe e, AllEmployeeSumoftaxablewag es.[Proces s level], AllEmployeeSumoftaxablewag es.Dept, AllEmployeeSumoftaxablewag es.[Check ID], AllEmployeeSumoftaxablewag es.[Pay Code], AllEmployeeSumoftaxablewag es.[DED Code], AllEmployeeSumoftaxablewag es.[TR-Dat e], AllEmployeeSumoftaxablewag es.[Check Date], AllEmployeeSumoftaxablewag es.Hours, AllEmployeeSumoftaxablewag es.[Wage-A mt], AllEmployeeSumoftaxablewag es.[Ded-Am t], AllEmployeeSumoftaxablewag es.[Taxabl e-Wages], AllEmployeeSumoftaxablewag es.Excess, AllEmployeeSumoftaxablewag es.[Job Code], AllEmployeeSumoftaxablewag es.[Work State], AllEmployeeSumoftaxablewag es.[Ded End Date], AllEmployeeSumoftaxablewag es.[Check Number], AllEmployeeSumoftaxablewag es.[Case Number], AllEmployeeSumoftaxablewag es.[File Number], AllEmployeeSumoftaxablewag es.EDM, AllEmployeeSumoftaxablewag es.Expr4, AllEmployeeSumoftaxablewag es.[SumOfT axable Wages],
IIf((AllEmployeeSumoftaxab lewages.[D ED Code] = 'TXFE' or (AllEmployeeSumoftaxablewa ges.[DED Code] = 'TXUN'),[LimitTaxableWages ], 28900)) as LimitTaxableWages
FROM AllEmployeeSumoftaxablewag es;
SELECT AllEmployeeSumoftaxablewag
IIf((AllEmployeeSumoftaxab
FROM AllEmployeeSumoftaxablewag
ASKER
What I really want it to do is have an iff statement like the following:
If the DED Code = TXFE or TXUN then LimitTaxableWages = 28900
If the DED Code = TXSC or TXSE then LimitTaxableWages = 106800
Please help me figure this expression out. Thank you!
If the DED Code = TXFE or TXUN then LimitTaxableWages = 28900
If the DED Code = TXSC or TXSE then LimitTaxableWages = 106800
Please help me figure this expression out. Thank you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OK, didn't get your last comment, just a second...
IIf ( AllEmployeeSumoftaxablewag es.[DED Code] = 'TXFE' or
AllEmployeeSumoftaxablewag es.[DED Code] = 'TXUN', 28900,
IIf ( AllEmployeeSumoftaxablewag es.[DED Code] = 'TXSC' or
AllEmployeeSumoftaxablewag es.[DED Code] = 'TXSE', 106800,
[Taxable-Wages] )) as LimitTaxableWages
Please check if [Taxable-Wages] is what you want to have if nothing of the DED Codes match.
AllEmployeeSumoftaxablewag
IIf ( AllEmployeeSumoftaxablewag
AllEmployeeSumoftaxablewag
[Taxable-Wages] )) as LimitTaxableWages
Please check if [Taxable-Wages] is what you want to have if nothing of the DED Codes match.
ASKER
OK, so how do you do a check to see if there is anything in a record?
What I am trying to do is if there is nothing in the AllEmployeeSumoftaxablewag es.[SumOfT axable Wages] record column, I want to insert into the SumOfTaxableWages whatever is in the AllEmployeeSumoftaxablewag es.[Taxabl e-Wages] colunn. How would I do an iif statement doing that? Does that make sense? Thank you very much on your help so far.
What I am trying to do is if there is nothing in the AllEmployeeSumoftaxablewag
Depending on your underlaying query "AllEmployeeSumoftaxablewa ges" the value for [SumOfTaxable Wages] could be NULL, 0 or <>0. I assume that the last two gives you valid information back, so I check only with "IsNull" in the IIf-Statement. The following return the sum, if not NULL:
IIf ( IsNull(AllEmployeeSumoftax ablewages. [SumOfTaxa ble Wages]),
AllEmployeeSumoftaxablewag es.[Taxabl e-Wages],
AllEmployeeSumoftaxablewag es.[SumOfT axable Wages] )
This returns the sum if <>0 and not NULL:
IIf ( AllEmployeeSumoftaxablewag es.[SumOfT axable Wages]<>0,
AllEmployeeSumoftaxablewag es.[SumOfT axable Wages],
AllEmployeeSumoftaxablewag es.[Taxabl e-Wages] )
IIf ( IsNull(AllEmployeeSumoftax
AllEmployeeSumoftaxablewag
AllEmployeeSumoftaxablewag
This returns the sum if <>0 and not NULL:
IIf ( AllEmployeeSumoftaxablewag
AllEmployeeSumoftaxablewag
AllEmployeeSumoftaxablewag
So, if there is something in [SumOfTaxable Wages] use that, other wise use [taxable-wages]
ie IIf ( Nz(AllEmployeeSumoftaxable wages.[Sum OfTaxable Wages],0) <> 0
AllEmployeeSumoftaxablewag es.[SumOfT axable Wages],
AllEmployeeSumoftaxablewag es.[Taxabl e-Wages] )
what does that have to do with :
If the DED Code = TXFE or TXUN then LimitTaxableWages = 28900, or, If the DED Code = TXSC or TXSE then LimitTaxableWages = 106800
ie IIf ( AllEmployeeSumoftaxablewag es.[DED Code] = 'TXFE' or AllEmployeeSumoftaxablewag es.[DED Code] = 'TXUN', 28900,
IIf ( AllEmployeeSumoftaxablewag es.[DED Code] = 'TXSC' or AllEmployeeSumoftaxablewag es.[DED Code] = 'TXSE', 106800,
0)) as LimitTaxableWages
or are they two seperate questions ?
ie IIf ( Nz(AllEmployeeSumoftaxable
AllEmployeeSumoftaxablewag
AllEmployeeSumoftaxablewag
what does that have to do with :
If the DED Code = TXFE or TXUN then LimitTaxableWages = 28900, or, If the DED Code = TXSC or TXSE then LimitTaxableWages = 106800
ie IIf ( AllEmployeeSumoftaxablewag
IIf ( AllEmployeeSumoftaxablewag
0)) as LimitTaxableWages
or are they two seperate questions ?
IIf((AllEmployeeSumoftaxab