V
Van T. Dinh
1. Your Table Structure is incorrect. You have 20
repeating groups of Field (MailingDates) and probably not
all of them are used for all Records. The correct design
is to separate the MailingDates out to a separate Table.
Read up on Relational Database Design Theory and Database
Normalisation and restructure your Table(s) accordingly. T
2. A ***temporary*** solution (since you will have other
problems later with the current Table Structure) is to use
the fnMax. Copy the posted code into a Standard Module:
'****
Public Function fnMax(ParamArray varValue() As Variant)
Dim varMax As Variant
Dim intIndex As Integer
On Error GoTo fnMax_Err
varMax = varValue(0)
For intIndex = 1 To UBound(varValue())
If varValue(intIndex) > varMax Then
varMax = varValue(intIndex)
End If
Next intIndex
fnMax = varMax
fnMax_Exit:
Exit Function
fnMax_Err:
Select Case Err.Number
Case 0
Case Else
MsgBox "Error " & Err.Number & ": " & _
Err.Description & vbCrLf & vbCrLf & _
"(Programmer's note: vbaMathematics.fnMax)" &
vbCrLf, _
vbOKOnly + vbCritical, "Run-time Error!"
End Select
Resume fnMax_Exit
End Function
'****
Save the Module with a unique name different from "fnMax".
Create a calculated Field in your Query:
MostRecent:fnMax(Date1, Date2, ..., Date20)
HTH
Van T. Dinh
MVP (Access)
repeating groups of Field (MailingDates) and probably not
all of them are used for all Records. The correct design
is to separate the MailingDates out to a separate Table.
Read up on Relational Database Design Theory and Database
Normalisation and restructure your Table(s) accordingly. T
2. A ***temporary*** solution (since you will have other
problems later with the current Table Structure) is to use
the fnMax. Copy the posted code into a Standard Module:
'****
Public Function fnMax(ParamArray varValue() As Variant)
Dim varMax As Variant
Dim intIndex As Integer
On Error GoTo fnMax_Err
varMax = varValue(0)
For intIndex = 1 To UBound(varValue())
If varValue(intIndex) > varMax Then
varMax = varValue(intIndex)
End If
Next intIndex
fnMax = varMax
fnMax_Exit:
Exit Function
fnMax_Err:
Select Case Err.Number
Case 0
Case Else
MsgBox "Error " & Err.Number & ": " & _
Err.Description & vbCrLf & vbCrLf & _
"(Programmer's note: vbaMathematics.fnMax)" &
vbCrLf, _
vbOKOnly + vbCritical, "Run-time Error!"
End Select
Resume fnMax_Exit
End Function
'****
Save the Module with a unique name different from "fnMax".
Create a calculated Field in your Query:
MostRecent:fnMax(Date1, Date2, ..., Date20)
HTH
Van T. Dinh
MVP (Access)