SQLite .DateValue Format Exception

dTempDate = rsRecall.Field("SubmissionDate").DateValue

Above code retrieves a SQLite field. When SubmissionDate contains a valid date all works fine. When it is nil, I get an UnsupportedFormatException.

If I code something like if (rsRecall.Field(“SubmissionDate”).DateValue) = nil then I get the same exception error.

How do I get a date value from the SQLite DateValue field.


You should check for Nil before you attempt to use its property:

If rsRecall.Field("SubmissionDate") <> Nil Then dTempDate = rsRecallField.Field("SubmissionDate").DateValue End If

Or possibly

if not rsRecall.Field("SubmissionDate").Value.IsNull Then
   dTempDate = rsRecall.Field("SubmissionDate").DateValue

Now I get it. It was adding the value parameter at the end that was causing the problem.

Thanks to both Paul and Tim. I know I can always get the correct answer here,