Hi, I need to use a function that works out the earliest date from different fields.
I'm currently using the following code provided from a Microsoft webpage:
The problem I'm having is I need to show the earliest date, but some fields can be null. So if the 1st parameter is null, the result is null even though there is a date in the second parameter.
I need it to show the earliest date even if the 1, 2 or 3 parameters are null, and the result to be null if all parameters are null.
I'm currently using the following code provided from a Microsoft webpage:
Code:
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
I need it to show the earliest date even if the 1, 2 or 3 parameters are null, and the result to be null if all parameters are null.