Creating a formula

T

taskusa

I need to create a formula that looks at 4 values in a field . The formula
then takes the higest of the four values and adds it to another field. Can
anybody help?
 
W

Whitless

How about this? I found it in one of the databases I administer, it compares
dates but could be adapted for number fields.

Public Function MaximumDate(ByVal Date1 As Date, ByVal Date2 As Date,
Optional ByVal Date3 As Date, Optional ByVal Date4 As Date) as Date
'function to determine the maximum date for up to four dates
Dim dtMaxDate As Date

dtMaxDate = Date1

If dtMaxDate < Date2 Then
dtMaxDate = Date2
End If

If dtMaxDate < Date3 Then
dtMaxDate = Date3
End If

If dtMaxDate < Date4 Then
dtMaxDate = Date4
End If

MaximumDate = dtMaxDate

End Function

So the query field would read

Max date: MaximumDate([DateField1],[DateField2],[Datefield3],[DateField4])

I hope this helps. However I am sure that the better Access guys will
suggest some nifty formula that can be used. Or basically shoot my function
down in flames.
 
Top