G
Guest
The below function works but returns wrong calculation after Elseif
I am new to making my own function and have been at this for days
Option Compare Database
Public Function calculatecommission(totalsales As Currency) As Currency
' Take Total Sales and calculate commission
Dim curcommission As Currency
If totalsales <= 1000 Then
curcommission = Forms!Payroll.totalsales * Forms!Payroll.commrate1
ElseIf totalsales <= 2500 Then
curcommission = Forms!Payroll.totalsales * Forms!Payroll.commrate2 *
Forms!Payroll.commrate1 - 1000
Else
curcommission = Forms!Payroll.totalsales * Forms!Payroll.commrate2 *
Forms!Payroll.commrate3 - 2500
End If
' return calculated amount
calculatecommission = curcommission
End Function
commrate 1, 2, and 3 are commission percentages assigned in employee table.
the calculation works for sales amount <= 1000 but fails to calculate
properly after that Can anyone point me in the right direction?
Thank You .. Roger
I am new to making my own function and have been at this for days
Option Compare Database
Public Function calculatecommission(totalsales As Currency) As Currency
' Take Total Sales and calculate commission
Dim curcommission As Currency
If totalsales <= 1000 Then
curcommission = Forms!Payroll.totalsales * Forms!Payroll.commrate1
ElseIf totalsales <= 2500 Then
curcommission = Forms!Payroll.totalsales * Forms!Payroll.commrate2 *
Forms!Payroll.commrate1 - 1000
Else
curcommission = Forms!Payroll.totalsales * Forms!Payroll.commrate2 *
Forms!Payroll.commrate3 - 2500
End If
' return calculated amount
calculatecommission = curcommission
End Function
commrate 1, 2, and 3 are commission percentages assigned in employee table.
the calculation works for sales amount <= 1000 but fails to calculate
properly after that Can anyone point me in the right direction?
Thank You .. Roger