return a null value to date field

  • Thread starter Thread starter LGarcia
  • Start date Start date
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
 
If you want to leave the field blank when both fields are null then
instead of assigning as "= Null" assign as a zero length string as "="".
 
thanks!
sorry for the double post!

kc-mass said:
If you want to leave the field blank when both fields are null then
instead of assigning as "= Null" assign as a zero length string as "="".
 
Back
Top