FInd a Range

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

Guest

Hi: I have a form that is basically being used as a calculator using Label
and Text fields. There are no tables, etc. I have 10 .txt fields named Y1
thru Y10. In this fields you enter returns, such as 15.00, -1.59, 79.00,
7.56 etc. Is there a way to build additional text feilds with a control
source (expression builder) that will search fields Y1 thru Y10 to find the
range? Or identify the low and high numbers that have been enetered? -1.59
to 79.00? Thanks.
 
Hi CP

Access has no built-in functions to find Min, Max, or range, but you can
write your own. Something like this should get you started:

Public Function Max(ParamArray Values()) As Variant
Dim i As Integer, vMax As Variant
vMax = Values(LBound(Values))
For i = LBound(Values) + 1 To UBound(Values)
If Values(i) > vMax Then vMax = Values(i)
Next
Max = vMax
End Function

Public Function Min(ParamArray Values()) As Variant
Dim i As Integer, vMin As Variant
vMin = Values(LBound(Values))
For i = LBound(Values) + 1 To UBound(Values)
If Values(i) < vMin Then vMin = Values(i)
Next
Min = vMin
End Function
 
Back
Top