set a date field to null

G

Guest

I have Dim InitialHSDate as Date, and do various calcs as I loop thru a
table. At each new record I want to set InitialHSDate to null and start the
calcs again fresh.

I tried InitialHSDate = "NULL" (= null)(= "") but none work.
Thanks,
Doug
 
R

Rick Brandt

Doug said:
I have Dim InitialHSDate as Date, and do various calcs as I loop thru
a table. At each new record I want to set InitialHSDate to null and
start the calcs again fresh.

I tried InitialHSDate = "NULL" (= null)(= "") but none work.
Thanks,
Doug

The ONLY variable type that can be set to Null is Variant. The default or
"fresh" value for a date is 12/30/1899 00:00:00 which is represented numerically
under the covers as zero. So just set InitialHSDate to zero instead of Null.
 
J

John W. Vinson

I have Dim InitialHSDate as Date, and do various calcs as I loop thru a
table. At each new record I want to set InitialHSDate to null and start the
calcs again fresh.

I tried InitialHSDate = "NULL" (= null)(= "") but none work.
Thanks,
Doug

A Date datatype variable cannot be NULL. Dim the field as a Variant instead,
and just set it to

= Null

with no quotes.

John W. Vinson [MVP]
 
G

Guest

Thanks John and Rick.

John W. Vinson said:
A Date datatype variable cannot be NULL. Dim the field as a Variant instead,
and just set it to

= Null

with no quotes.

John W. Vinson [MVP]
 

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