Question Help with multiple IIF statements

Also surprised at the Switch() performance.

FFS and RangeValue are declared variables? Looking at prior posts, they appear to be number datatype. Don't see anything wrong with the construct. The parens are not needed but shouldn't hurt. Following should work as well

strWhere = "FFS = " & FFS & " AND " & RangeValue & " BETWEEN RangeLow AND RangeHigh"

Is your table actually named "sometable"?
 
Just checked and the code is based on MajP's 'guess' about table structure
Did you implement that in full?
If so, June's suggestion is the most concise but all versions really should work
 
Hahaha I know it has been so long but I have a great excuse... I celebrated the birth of my 3rd child and haven't had as much time as you could imagine.

I did implement MajP's structure and have defined StrWhere. I also just implemented the change June7 recommended and table is named "Federal Tax Tables". Now I am running into the issue Run-Time error "2471" The expression you entered as a query parameter produced this error: 'SubFactor'.

Here is what I have so far...

Public Function GetValue(FFS As Integer, GrossWages As Double, Deductions As Double, Withholding As Double)
Dim SubFactor As Long
Dim Multiple As Double
Dim AddFactor As Double
Dim strWhere As String
Dim RangeValue As Double

RangeValue = GrossWages - (Withholding * Deductions)
strWhere = "FFS = " & FFS & " AND " & RangeValue & " BETWEEN RangeLow AND RangeHigh"

Multiple = Nz(DLookup("multiple", "Federal Tax Tables", strWhere), 0)
SubFactor = Nz(DLookup("SubFactor", "Federal Tax Tables", strWhere), 0)
AddFactor = Nz(DLookup("AddFactor", "Federal Tax Tables", strWhere), 0)
GetValue = ((RangeValue - SubFactor) * Multiple + AddFactor)
End Function
 
I FIGURED IT OUT!!! I just wanted to say thank you all so much for all your help with all of this!
 
Congratulations on figuring it out and more importantly on your new child :)
 

Users who are viewing this thread

Back
Top Bottom