Hello everybody - Need help again.
I have a non-normalised (as I believe) database, having three fields (a, b
and c), in which my colleaques record numbers. How can I find the maximum
number recorded in those fields for each record?
Thanking you in advance
Michel Walsh - 28 Apr 2006 11:30 GMT
Hi,
iif( a> b, iif( a>c, a, c), iif(b>c, b, c))
Hoping it may help,
Vanderghast, Access MVP
> Hello everybody - Need help again.
>
[quoted text clipped - 3 lines]
>
> Thanking you in advance
Dale Fye - 28 Apr 2006 13:41 GMT
George,
Another option is to create a function to do the comparison for you. I
wrote this a number of years ago when I was working with dates a lot, and
needed to know the larger of two dates. I later expanded it to take as many
arguments as I wanted, when one of my clients had the same problem you have,
but more columns. You can pass this function any number of arguments (fields
in your case) and it will return the largest value.
Public Function MaxVal(ParamArray MyArray()) As Variant
Dim varMax As Variant
Dim intLoop As Integer
varMax = Null
For intLoop = LBound(MyArray) To UBound(MyArray)
If IsNull(MyArray(intLoop)) Then
'do nothing
ElseIf IsNull(varMax) Or MyArray(intLoop) > varMax Then
varMax = MyArray(intLoop)
End If
Next
MaxVal = varMax
End Function
HTH
Dale
> Hello everybody - Need help again.
>
[quoted text clipped - 3 lines]
>
> Thanking you in advance