What is the value of an empty date field?

  • Thread starter Thread starter Blake Farren
  • Start date Start date
B

Blake Farren

Hello, I have programmed a function to calculate the number of 15
minute time units from a start and finish time. With these two times
declared as date variables when the function runs with time fields
that have no values in the fields I get an #ERROR in the calculated
field. I have tried various ways to get around this, but my question
is 'what does VBA assign as a default value to a date/time field that
is empty?'. I am running Access XP. Your help is very appreciated..
thanks Blake Farren (e-mail address removed)
 
My guess would be 0.

So you should be ok if you check the fields to be non-zero
i.e.
if time1 <> 0 and time2 <> 0 then
code here

Hope This Helps
Gerald Stanley MCSD
 
The default value of a Date/Time *field* is NULL. In code, you test for
this with the IsNull() function. So rather than:
If MyVariable = Null Then
you would use:
If IsNull(MyVariable) Then
 
empty date is "12:00:00 AM" if the date is dim as "Date" . If it is dim as
variant, you can use isEmpty function to determine that.
 
A field without any value in it is Null.

If you attempt to use DateAdd(), the first 2 arguments are required, but the
3rd may be Null.
 
Not quite. A date/time variable defaults to 0. This seems fair, since
date/time variables are not variants, and do not allow null. But a date/time
field in a table is like any other table field (except for yes/no fields):
it >does< allow null, and will default to null.

HTH,
TC
 
Back
Top