Yes. Copy his code to the clipboard, starting with the first function and ending with the second. like so:
--Start copy after arrow---->
Function fIsNull(dIn) As Date
If IsNull(dIn) Or dIn = "" Or dIn = " " Then
fIsNull = CDate("01/01/1001"

Else
fIsNull = dIn
End If
End Function
Function fNewest(d1 As Date, d2 As Date, d3 As Date, d4 As Date, d5 As Date) As Integer
On Error GoTo errHandler
Dim dtNew As Date
dtNew = d1
dtNew = IIf(d2 > dtNew, d2, dtNew)
dtNew = IIf(d3 > dtNew, d3, dtNew)
dtNew = IIf(d4 > dtNew, d4, dtNew)
dtNew = IIf(d5 > dtNew, d5, dtNew)
Select Case dtNew
Case d1
fNewest = 1
Case d2
fNewest = 2
Case d3
fNewest = 3
Case d4
fNewest = 4
Case d5
fNewest = 5
End Select
Exit Function
errHandler:
MsgBox (Err.Number & " : " & Err.Description)
End Function
<----End copy before arrow------
Now go to modules and click on new. Paste in the code at the end of the module. Close the module. The module name does not matter, so leave it as Module1.
You may now use his functions as he described above: Click on query builder. Click on design view. Cancel on the "choose tables" dialog box. At the top left there is an icon labeled "SQL". CLick on it. Paste in the SQL he wrote above:
SELECT fNewest(fIsNull([date1]),fIsNull([date2]),fIsNull([date3]),fIsNull([date4]),fIsNull([date5])) AS Newest, Count(tblDateQ.CName) AS RecCount
FROM tblDateQ
GROUP BY fNewest(fIsNull([date1]),fIsNull([date2]),fIsNull([date3]),fIsNull([date4]),fIsNull([date5]));
Now click on the icon to get to design view again.
Save the query and you are done.
PS--next time consider setting up your table structure differently so that you don't have five fields storing the same information. Set them up in a new table, then you can easily get the maximum, minimum, average, count, etc from the list. This question is a prime example of why "table normalization" is useful.
--
Find common answers using Google Groups:
Corrupt MDBs FAQ