G
Gina Whipp
To my FAVORITE guys (and gals) in the whole world... (okay =, I need help)
Below: Example A does not work but Example B does.
What I want is the Skid to take a letter, eith G or J and hunt the table for
the size. Which it does but only if I put the letter (and I'm not chnaging
the code everytime I want to switch between G and J), not if I use Skid
which means you should be able to enter either letter. Can someone tell me
why Example A won't let me choose the letter and returns a value of 0 (if I
use Example B I get the correct value of 30)
Big THANKS!
Gina
Example A:
Public Function SkidPrice(ByVal Skid As String, ByVal Width As Single, ByVal
Length As Single) As Single
If Length > 500 Then Length = 999
Crit = "([spFromLength] <= " & Length & ") "
Crit = Crit & "And ([spFromWidth] <= " & Width & ") "
Crit = Crit & "And ([spToLength] >= " & Length & ") "
Crit = Crit & "And ([spToWidth] >= " & Width & ") "
Crit = Crit & "And ([spItemID] = '" & Skid & "') "
UnitPrice = Nz(DLookup("spPrice", "tblStandardPricing", Crit))
If IsNull(UnitPrice) Then UnitPrice = 0
SkidPrice = UnitPrice
End Function
Examble B
Public Function SkidPrice(ByVal Skid As String, ByVal Width As Single, ByVal
Length As Single) As Single
If Length > 500 Then Length = 999
Crit = "([spFromLength] <= " & Length & ") "
Crit = Crit & "And ([spFromWidth] <= " & Width & ") "
Crit = Crit & "And ([spToLength] >= " & Length & ") "
Crit = Crit & "And ([spToWidth] >= " & Width & ") "
Crit = Crit & "And ([spItemID] = '" & "G" & "') "
UnitPrice = Nz(DLookup("spPrice", "tblStandardPricing", Crit))
If IsNull(UnitPrice) Then UnitPrice = 0
SkidPrice = UnitPrice
End Function
Below: Example A does not work but Example B does.
What I want is the Skid to take a letter, eith G or J and hunt the table for
the size. Which it does but only if I put the letter (and I'm not chnaging
the code everytime I want to switch between G and J), not if I use Skid
which means you should be able to enter either letter. Can someone tell me
why Example A won't let me choose the letter and returns a value of 0 (if I
use Example B I get the correct value of 30)
Big THANKS!
Gina
Example A:
Public Function SkidPrice(ByVal Skid As String, ByVal Width As Single, ByVal
Length As Single) As Single
If Length > 500 Then Length = 999
Crit = "([spFromLength] <= " & Length & ") "
Crit = Crit & "And ([spFromWidth] <= " & Width & ") "
Crit = Crit & "And ([spToLength] >= " & Length & ") "
Crit = Crit & "And ([spToWidth] >= " & Width & ") "
Crit = Crit & "And ([spItemID] = '" & Skid & "') "
UnitPrice = Nz(DLookup("spPrice", "tblStandardPricing", Crit))
If IsNull(UnitPrice) Then UnitPrice = 0
SkidPrice = UnitPrice
End Function
Examble B
Public Function SkidPrice(ByVal Skid As String, ByVal Width As Single, ByVal
Length As Single) As Single
If Length > 500 Then Length = 999
Crit = "([spFromLength] <= " & Length & ") "
Crit = Crit & "And ([spFromWidth] <= " & Width & ") "
Crit = Crit & "And ([spToLength] >= " & Length & ") "
Crit = Crit & "And ([spToWidth] >= " & Width & ") "
Crit = Crit & "And ([spItemID] = '" & "G" & "') "
UnitPrice = Nz(DLookup("spPrice", "tblStandardPricing", Crit))
If IsNull(UnitPrice) Then UnitPrice = 0
SkidPrice = UnitPrice
End Function