projecttoday
Registered User.
- Local time
- Today, 06:04
- Joined
- Jan 5, 2011
- Messages
- 51
I have a function that I use in queries to convert numbers into dates. If a number is not a value we are looking for, then the function should return a null. The dates come out correct. The numbers that do not qualifty come out as 12/31/1899.
This is the function:
Invalid dates in the input come up as 12/31/1899 in Access. Since I don't want 12/31/1899 to show on my forms and reports I have to add code that sets 12/31/1899 to "". It would be simpler if i could put an actual null value in the table. Is this possible? Changing vbNull to Null or "" causes an error.
This is the function:
Code:
Public Function ConvertDate(InDate As Long) As Date
Dim lngIndate As Long, strIndate As String
' if it is not a valid date in the yyymmdd format, set it to
If InDate < 1010101 Or InDate > 1300101 Or InDate = 999999 Then
[B]ConvertDate = vbNull <--- this is where 12/31/1899 comes in[/B]
Else
lngIndate = InDate + 19000000
strIndate = lngIndate
ConvertDate = Mid(strIndate, 5, 2) & "/" & Mid(strIndate, 7, 2) & "/" & Left(strIndate, 4)
End If
End Function
Invalid dates in the input come up as 12/31/1899 in Access. Since I don't want 12/31/1899 to show on my forms and reports I have to add code that sets 12/31/1899 to "". It would be simpler if i could put an actual null value in the table. Is this possible? Changing vbNull to Null or "" causes an error.