What is the value of an empty date field?

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)
 
G

Gerald Stanley

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
 
R

Roger Carlson

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
 
P

Phil Hunt

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

Allen Browne

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.
 
T

TC

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top