Gustav Brock
gustav at cactus.dk
Wed Oct 1 04:58:31 CDT 2003
Hi Gowey
On a more serious note, here is a function taking advantage of the
nice ParamArray feature. It can be used for any (reasonable) amount
(including zero) input values:
<code>
Public Function DateMax(ParamArray avarDates() As Variant) As Date
' Return maximum date/time value of elements in
' array avarDates().
' If no elements of array avarDates() are dates,
' value of cdatEmpty is returned.
'
' 2003-09-30. Cactus Data ApS, CPH.
' Return value for an empty array.
Const cdatEmpty As Date = #1/1/100#
Dim varDate As Variant
Dim varDateMax As Variant
For Each varDate In avarDates()
If IsDate(varDate) Then
If VarType(varDate) <> vbDate Then
varDate = CDate(varDate)
End If
If varDate > varDateMax Then
varDateMax = varDate
End If
End If
Next
If IsEmpty(varDateMax) Then
varDateMax = cdatEmpty
End If
DateMax = varDateMax
End Function
</code>
For your display textbox, use
=DateMax(Me!txtBox1, Me!txtBox2, ... , Me!txtBox6)
/gustav
> This is probably an easy one but I am stumped...
> I have 6 fields within my table that have dates in them, how can
> I pull and display on a form which field has the most recent date in it?