PaulaJ....Here's my take:
Assumption: you have five fields, each possibly with a date, available in the query which is the recordsource of your report or as hidden fields in your report.
Solution: Start a new module and paste the following code in:
' ************** Start Code ************
Public Function GetDate(Optional dteDate1 As Date = #12/31/1899#, Optional dteDate2 As Date = #12/31/1899#, Optional dteDate3 As Date = #12/31/1899#, Optional dteDate4 As Date = #12/31/1899#, Optional dteDate5 As Date = #12/31/1899#) As Date
If dteDate5 <> #12/31/1899# Then
GetDate = dteDate5
Exit Function
End If
If dteDate4 <> #12/31/1899# Then
GetDate = dteDate4
Exit Function
End If
If dteDate3 <> #12/31/1899# Then
GetDate = dteDate3
Exit Function
End If
If dteDate2 <> #12/31/1899# Then
GetDate = dteDate2
Exit Function
End If
GetDate = dteDate1
End Function
' ************** End Code **************
If using a query, add a new field at the end and use:
ReportDate: =GetDate([Field1],[Field2],[Field3],[Field4],[Field5])
in the field line and then set the controlsource of the field in the report to:
[ReportDate]
If in the report directly, it is basically the same....using the OnFormat event of the section in question, put:
Me![reportfieldnametodisplaydate] = GetDate(Me![Field1], Me![Field2], Me![Field3], Me![Field4], Me![Field5])
This basically takes the input, and checks it. If there is no date for any of the fields, it sets the date to the bogus date of 12/31/1899. It then walks backwards and looks for the first date not equal to 12/31/1899....and retuns that date...
Any Questions???
=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)
Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com