If Statement Pay rate based on efficiency

  • Thread starter Thread starter Gonzalo
  • Start date Start date
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]
 
Just build the IIf statement in the expression:

New Pay Rate: IIf([Efficiency]*[Pay Rate] < [Pay Rate], [Pay Rate],
([Efficiency]*[Pay Rate])
 
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])
 
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]
 
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
 
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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top