Assumption: You have three date fields in one record (row).
The best way would be to redesign your table structure to store the dates as
separate related records in another table. Or use a union query to fix the data.
The easiest way is to use a VBA function - especially if you have no control
over the data being supplied. Below is a function that should work for you.
In your query you would have a calculated column.
Field: LastDate: fGetRowMax([DateOne],[DateTwo],[DateThree])
Copy this function into a VBA module in your database. Save the module with
some name other than fGetRowMax.
Public Function fGetRowMax(ParamArray Values()) As Variant
'John Spencer UMBC CHPDM
'Last Update: April 5, 2000
'Returns the Maximum of a group of values passed to it.
'Sample call:
' fGetRowMax("-21","TEST","2", "3","4","5","6","7",0) returns "TEST"
' fGetRowMax(-21,2,3,4,5,6,7,0) returns 7
' Handles text, date, or number fields -
' only one type of data should be passed in
' Max of 29 values if called from a query.
Dim i As Long, vMax As Variant
vMax = Null
For i = LBound(Values) To UBound(Values)
If IsNull(Values(i)) = False Then
If Values(i) <= vMax Then
Else
vMax = Values(i)
End If
End If
Next
fGetRowMax = vMax
End Function
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County