Round a Calculations

  • Thread starter Thread starter serviceenvoy
  • Start date Start date
S

serviceenvoy

For labor, we add $50 to our cost and then round to the next highest
$25 increment. So if
the cost was $124, we add $50 using an Iif Statement (iif"laborcost>0,
laborcost+50,0), we would want to round it to the next highest $25
increment so instead of being $174 it would be $175. How can I do
this in a formula or event procedure?


On parts, we like to round to the next highest .99 so if the part was
$7.23, we would want to round that to $7.99.
Can that be done very easily?
 
For labor, we add $50 to our cost and then round to the next highest
$25 increment. So if
the cost was $124, we add $50 using an Iif Statement (iif"laborcost>0,
laborcost+50,0), we would want to round it to the next highest $25
increment so instead of being $174 it would be $175. How can I do
this in a formula or event procedure?

=Int(((IIf"laborcost>0, laborcost+50,0)+24.99)/25)*25

On parts, we like to round to the next highest .99 so if the part was
$7.23, we would want to round that to $7.99.

=Int(partcost) + .99
 
You can use the following formula in Access which you can call from VBA or
queries

Function FinalLaborCost(LaborCost As Double) As Double
Dim tempCost As Double
Dim intMod As Integer

'add 50 extra fee
tempCost = LaborCost + 50
'figure out if this is divisible by 25
'must multiply both sides by 100 to take care of any extra decimals
intMod = tempCost * 100 Mod 2500
If intMod = 0 Then
'do not round if divisible by 25
FinalLaborCost = tempCost
Else
'round down to get the number of times that 25 goes into cost
intMod = Int(tempCost / 25)
'add one and multiply by 25 to get next highest 25
FinalLaborCost = (intMod + 1) * 25
End If

End Function

Function Nearest99(Cost As Double) As Double
Dim tempCost As Double

'find out how many cents are in the cost
tempCost = Cost - Int(Cost)
'due to decimal issues compare that *100 to 99
If Int(tempCost * 100) = 99 Then
'if it ends with 99 then leave the cost
Nearest99 = Cost
Else
'otherwise add 0.99 to the dollar value
Nearest99 = Int(Cost) + 0.99
End If
End Function


Please let me know if I can provide any other assistance.
 
Back
Top