Question Help with multiple IIF statements (1 Viewer)

June7

AWF VIP
Local time
Today, 15:36
Joined
Mar 9, 2014
Messages
5,423
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"?
 

isladogs

MVP / VIP
Local time
Today, 23:36
Joined
Jan 14, 2017
Messages
18,186
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
 

Cassidy7782

New member
Local time
Today, 16:36
Joined
Nov 2, 2018
Messages
6
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
 

Cassidy7782

New member
Local time
Today, 16:36
Joined
Nov 2, 2018
Messages
6
I FIGURED IT OUT!!! I just wanted to say thank you all so much for all your help with all of this!
 

isladogs

MVP / VIP
Local time
Today, 23:36
Joined
Jan 14, 2017
Messages
18,186
Congratulations on figuring it out and more importantly on your new child :)
 

Users who are viewing this thread

Top Bottom