ashleybyrdnc
MIS
In my form I have 4 different date fields, and I need to return the largest of those date in another field. I have tried the Max() but it doesn't work with multi fields, any suggestions?
Thanks
Thanks
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
'-----------------------------------------------------------
' Procedure : MaxVal
' Purpose : Return the maximum value of the supplied values
' Arguments : Vals() - Array of Values
'-----------------------------------------------------------
'
Public Function MaxVal(ParamArray Vals() As Variant) As Variant
Dim x As Variant
Dim MV As Variant
MV = Vals(0)
For Each x In Vals
If Not IsNull(x) Then
If IsNull(MV) Then
MV = x
ElseIf x > MV Then
MV = x
End If
End If
Next
MaxVal = MV
End Function
MaxDate = MaxVal(Date1, Date2, Date3, Date4)
'A generic function to get the max value of an arbirtrary numbers of same type values:
Public Function myMax(ParamArray Args())
Dim i As Long, rv
For i = 0 To UBound(Args)
If IsNull(rv) Or rv < Args(i) Then rv = Args(i)
Next
'A generic function to get the max value of an arbirtrary numbers of same type values:
Public Function myMax(ParamArray Args())
Dim i As Long, rv
For i = 0 To UBound(Args)
If IsNull(rv) Or rv < Args(i) Then rv = Args(i)
Next
myMax = rv
End Function
? MaxVal ( 1, 99, NULL, 4, 5 )