Null Date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I clear the value of a "date" variable and make it equal to "null". I
am looping thru a recordset and want the value of the date field to be
updated to null.

I have tried: myDate = Empty and myDate = null without sucess.

..edit
!Date = myDate
..update


Thank you


Ross
 
I know that I can do this but:

1. I would rather update at (to null) at the moment that I know that it
should be null.
2. It would cost more time to process / update after my recordset procedure
is done.
3. I would like the process to be as clean as possible.

Thanks
 
What is wrong? You have tried, but how did it fail?

Does your field allow Nulls at all?
 
The Field allows null but the variable doesn't. When I set the variable
equal the null, ie myDate = null, this will error as not valid.

The Variable is :
Dim myDate as Date

I want to set the variable and then post the variable (value = null) to the
!Date Field
 
I want to set the variable and then post the variable (value = null)
to the !Date Field

If you want a _variable_ to hold a null value, it has to be a Variant

Dim varMyDate as Variant

varMyDate = Null

rs.fields("SomeDateField") = varMyDate

' etc...

VB and VBA has what is called stong typing (well, fairly strong), which
means that you can only put dates in a Date variable, strings in a String
field, and so on. It's a bit lax about converting stuff, though, which can
give the programmer a false sense of what is going on: for example

dtMyDate = "15/12/2004"

would never be allowed in a real language like Pascal. <ducking /> On the
other hand, it's the only way round some nasty editor bugs in VB. The
existence of Variants also muddies the water, but is the way to handle
things like Optional arguments, null values, etc etc. It's probably a
reasonable compromise between the rigour of really strongly-typed languages
and the anything-goes of VBS.

A field object can, on the other hand, hold any value that is legal for the
field - this may or may not be NULL, may or may not be a zero length
string, and so on.

Hope that helps


Tim F
 
Back
Top