Text Box Calculation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 3 textboxes on a report that total number of unit sales between
specific dates. I want to add a textbox and have it calculate the highest
number of the other 3 to use in another calculation
 
caseyalta said:
I have 3 textboxes on a report that total number of unit sales between
specific dates. I want to add a textbox and have it calculate the highest
number of the other 3 to use in another calculation


=IIf(t1 > IIf(t2 > t3, t2, t3), t1, IIf(t2 > t3, t2, t3))

That kind of expression gets very messy very quickly, so
it's almost always better to create a function to do the
calculation:

Public Function MaxOfList(ParamArray vValues() As Variant)
As Variant
Dim vX As Variant

MaxOfList = vValues(0)
For Each vX In vValues
If vX >= Nz(MaxOfList, vX) Then MaxOfList = vX
Next vX
End Function
 
Back
Top