If Statement Pay rate based on efficiency

G

Gonzalo

In my query I'm calculating employee pay rate based on efficiency. New Pay
Rate: [Efficiency]*[Pay Rate], I need to add an If statement, If employee New
Pay Rate is less than [Pay Rate] then New Pay Rate is equal to [Pay Rate]
 
K

Ken Snell \(MVP\)

Just build the IIf statement in the expression:

New Pay Rate: IIf([Efficiency]*[Pay Rate] < [Pay Rate], [Pay Rate],
([Efficiency]*[Pay Rate])
 
M

Marshall Barton

Gonzalo said:
In my query I'm calculating employee pay rate based on efficiency. New Pay
Rate: [Efficiency]*[Pay Rate], I need to add an If statement, If employee New
Pay Rate is less than [Pay Rate] then New Pay Rate is equal to [Pay Rate]


NewPayRate: IIf(Efficiency<1, [Pay Rate], Efficiency*[Pay
Rate])
 
J

John W. Vinson

In my query I'm calculating employee pay rate based on efficiency. New Pay
Rate: [Efficiency]*[Pay Rate], I need to add an If statement, If employee New
Pay Rate is less than [Pay Rate] then New Pay Rate is equal to [Pay Rate]

NewPayRate: IIF(NZ([Efficiency],1) <= 1, [Pay Rate], [Efficiency] * [Pay
Rate])

John W. Vinson [MVP]
 
D

Dale Fye

I have a function I use for this type of stuff. Copy this function and paste
it in a code module You can pass it as many parameters as you want, and it
will return the maximum value from among the values passed to it.

You would us it like:
NewPayRate: fnMaximum([Pay Rate], [Efficiency] * [Pay Rate])

Public Function fnMaximum(ParamArray MyArray() As Variant) As Variant

Dim myMax As Variant
Dim intLoop As Integer

For intLoop = LBound(MyArray) To UBound(MyArray)
If IsNull(MyArray(intLoop)) Then
'do nothing
ElseIf IsNull(myMax) Then
myMax = MyArray(intLoop)
ElseIf MyArray(intLoop) > myMax Then
myMax = MyArray(intLoop)
End If
Next
fnMaximum = myMax

End Function

HTH
Dale
 
G

Gonzalo

Thank you, your advise worked.

John W. Vinson said:
In my query I'm calculating employee pay rate based on efficiency. New Pay
Rate: [Efficiency]*[Pay Rate], I need to add an If statement, If employee New
Pay Rate is less than [Pay Rate] then New Pay Rate is equal to [Pay Rate]

NewPayRate: IIF(NZ([Efficiency],1) <= 1, [Pay Rate], [Efficiency] * [Pay
Rate])

John W. Vinson [MVP]
 
Top