L
LGarcia
Hi all,
I took a stab at writing a function. I am comparing 2 date fields. I need to
return either the latest date or which ever one isn't null. If both are null
then leave it blank. I'm getting an invalid use of null error. Hope someone
can help. Here's the code:
Thanks,
LGarcia
Function GrantsDate(strSubmitDate, strAwardDate) As Variant
Dim strReportDate As Variant
If IsNull(strSubmitDate) And IsNull(strAwardDate) Then
strReportDate = Null '********gives invalid use of null error*******
End If
If IsNull(strSubmitDate) And Not IsNull(strAwardDate) Then
strReportDate = strAwardDate
End If
If Not IsNull(strSubmitDate) And IsNull(strAwardDate) Then
strReportDate = strSubmitDate
End If
If Not IsNull(strSubmitDate) And Not IsNull(strAwardDate) Then
If strSubmitDate > strAwardDate Then
strReportDate = strSubmitDate
Else
strReportDate = strAwardDate
End If
End If
GrantsDate = strReportDate
End Function
I took a stab at writing a function. I am comparing 2 date fields. I need to
return either the latest date or which ever one isn't null. If both are null
then leave it blank. I'm getting an invalid use of null error. Hope someone
can help. Here's the code:
Thanks,
LGarcia
Function GrantsDate(strSubmitDate, strAwardDate) As Variant
Dim strReportDate As Variant
If IsNull(strSubmitDate) And IsNull(strAwardDate) Then
strReportDate = Null '********gives invalid use of null error*******
End If
If IsNull(strSubmitDate) And Not IsNull(strAwardDate) Then
strReportDate = strAwardDate
End If
If Not IsNull(strSubmitDate) And IsNull(strAwardDate) Then
strReportDate = strSubmitDate
End If
If Not IsNull(strSubmitDate) And Not IsNull(strAwardDate) Then
If strSubmitDate > strAwardDate Then
strReportDate = strSubmitDate
Else
strReportDate = strAwardDate
End If
End If
GrantsDate = strReportDate
End Function