First this problem started when I wanted to use Switch Function in a Query field like this one
But it gave me a Warning "Switch function is too complex" something like this
So I Tried the VBA Function() Using Case Code like this
this sure will return the value that I want but, What I need now is how to use the Case else if the Num is >20000 and return true [Price] field Value
Please Enlighten me as I'm just a Newbie with programming .. Thank you..
Nevermind, I've found the way out, didn't think about using a function in a function
In the Query Field
Code:
Amount: Switch([Price]<=10,10,[Price]<=20,20,[Price]<=50,50,[Price]<=100,100,[Price]<=200,200,[Price]<=300,300, [Price]<=400,400,[Price]<=500,500,[Price]<=600,600,[Price]<=700,700,[Price]<=800,800,[Price]<=1000,1000,[Price]<=2000,2000,[Price]<=3000,3000, [Price]<=5000,5000,[Price]<=10000,10000,[Price]<20000,20000,[Price]>=20000,[Price])
But it gave me a Warning "Switch function is too complex" something like this
So I Tried the VBA Function() Using Case Code like this
Code:
Function CoNum(Num As Double) As Double
Select Case Num
Case 0 To 10
CoNum = 10
Case 11 To 20
CoNum = 20
Case 21 To 50
CoNum = 50
Case 51 To 100
CoNum = 100
Case 101 To 200
CoNum = 200
Case 201 To 300
CoNum = 300
Case 301 To 400
CoNum = 400
Case 401 To 500
CoNum = 500
Case 501 To 600
CoNum = 600
Case 601 To 700
CoNum = 700
Case 701 To 800
CoNum = 800
Case 801 To 1000
CoNum = 1000
Case 1001 To 2000
CoNum = 2000
Case 2001 To 3000
CoNum = 3000
Case 3001 To 5000
CoNum = 5000
Case 5001 To 10000
CoNum = 10000
Case 10001 To 19999
CoNum = 20000
End Select
this sure will return the value that I want but, What I need now is how to use the Case else if the Num is >20000 and return true [Price] field Value
Please Enlighten me as I'm just a Newbie with programming .. Thank you..
Nevermind, I've found the way out, didn't think about using a function in a function
In the Query Field
Code:
Amount: IIf([Price]>20000,[Price],CoNum([Price]))
Last edited: