Article ID: 182760
Article Last Modified on 1/22/2007
Function Minimum(ParamArray FieldArray() As Variant)
' Declare the two local variables.
Dim I As Integer
Dim currentVal As Variant
' Set the variable currentVal equal to the array of values.
currentVal = FieldArray(0)
' Cycle through each value from the row to find the smallest.
For I = 0 To UBound(FieldArray)
If FieldArray(I) < currentVal Then
currentVal = FieldArray(I)
End If
Next I
' Return the minimum value found.
Minimum = currentVal
End Function
Function Maximum(ParamArray FieldArray() As Variant)
' Declare the two local variables.
Dim I As Integer
Dim currentVal As Variant
' Set the variable currentVal equal to the array of values.
currentVal = FieldArray(0)
' Cycle through each value from the row to find the largest.
For I = 0 To UBound(FieldArray)
If FieldArray(I) > currentVal Then
currentVal = FieldArray(I)
End If
Next I
' Return the maximum value found.
Maximum = currentVal
End Function
Table: tblMinMax
---------------------------
Field Name: Field1
Data Type: Number
Field Size: Long Integer
Field Name: Field2
Data Type: Number
Field Size: Long Integer
Field Name: Field3
Data Type: Number
Field Size: Long Integer
Field1 Field2 Field3
------ ------ ------
50 30 40
40 50 30
30 40 50
Minimum Value: Minimum([Field1],[Field2],[Field3])
Maximum Value: Maximum([Field1],[Field2],[Field3])
Additional query words: inf Min Max DMin DMax Largest Smallest
Keywords: kbdtacode kbhowto kbprogramming KB182760