calculation help

C

Carlee

Hi there, I am hoping someone can help with my calculation error: I am
trying to convert a formula into a workable solution in Access but am not
getting the right results.

the function is: Min(TV *.1*.08, max(PrintCount-1.2(tv))*.08)

in my query i have this: min_max_result:min_max([tv],[printcount])

in a module I have this:
function min_max(tv,printcount)
dim result_tv as double
dim result_print_count as double
dim temp_result as double

result_tv = TV*(.1)*(.08)
result_printcount=PrintCount]-(1.2)*(TV)) * (.08)

if result_tv < result_printcount then
temp_result =result_tv
else
temp_result =result_printcount
end if

min_max=temp_result
end function


In the original function I should get a result of $44.80, but when I
implement this code, i get 0. Can anyone see why?

Thanks in advance

Carlee
 
S

SteveS

Carlee said:
Hi there, I am hoping someone can help with my calculation error: I am
trying to convert a formula into a workable solution in Access but am not
getting the right results.

the function is: Min(TV *.1*.08, max(PrintCount-1.2(tv))*.08)

in my query i have this: min_max_result:min_max([tv],[printcount])

in a module I have this:
function min_max(tv,printcount)
dim result_tv as double
dim result_print_count as double
dim temp_result as double

result_tv = TV*(.1)*(.08)
result_printcount=PrintCount]-(1.2)*(TV)) * (.08)

if result_tv < result_printcount then
temp_result =result_tv
else
temp_result =result_printcount
end if

min_max=temp_result
end function


In the original function I should get a result of $44.80, but when I
implement this code, i get 0. Can anyone see why?

Thanks in advance

Carlee

Carlee,

What values for [TV] and [PrintCount] did you use to get the result of $44.80?

Are [TV] and [PrintCount] currency, double, single, ???

I don't understand why Max() is used when there is only one value in the Max()
function.


I modified your function; here it is:


'********** begin code ********
Function min_max(v_TV As Double, v_PC As Double) As Double
Dim result_tv As Double
Dim result_print_count As Double

'.1*.08=.008
result_tv = v_TV * (0.008)

result_print_count = (v_PC - (1.2 * v_TV)) * (0.08)

If result_tv < result_printcount Then
min_max = result_tv
Else
min_max = result_printcount
End If

End Function

'********** end code **********
 
Top