Click to See Complete Forum and Search --> : How to make a date Variable empty ?


November 28th, 1999, 10:54 AM
How can I make a date variable assigned empty like we do with strings by setting ""

santulan
November 28th, 1999, 11:39 AM
Hi,

Use NULL to assing a blank in date field.

or alternatively -
in INSERT INTO statement do not include the date fields, it will automatically be blank.



Santulan

Robert_Mathews99
November 29th, 1999, 03:47 AM
My problem is as below regarding dates

Dim StartDate as Date

StartDate = #10/01/1999#

...
...
...

Now I want to make the variable empty

I tried to issue null

StartDate = Null

'' Giving Error

Check out this

Ravi Kiran
November 29th, 1999, 03:56 AM
use vbNull

RK

santulan
November 29th, 1999, 10:23 AM
In access if you update and set date = "" date gets blank.
or you try vbNull

Santulan

greeneto
December 16th, 2010, 12:38 PM
I realize I'm writing this 11 years after the initial query, but the advice given is erroneous, and so I'm adding this so others who see this page are not misled. vbNull is intended strictly for use with the VarType() function to test if a variable is Null, as follows:

If VarType(abc) = vbNull Then

You cannot use vbNull to set a variable to Null. Indeed, if you try it, like so:

abc = vbNull

then the variable will actually be assigned a value of 1 (or "1" if it's a string variable). So if you do that then obviously an IsNull() test would fail to work properly because the variable is not null.

My understanding is that for a code variable you can't actually assign a Null to it unless it's a Variant data type (unlike an Access table field, which you can assign as Null). So a string variable must be assigned as empty string and a numeric must be assigned zero (or whatever else you want to used to signify as "unassigned" in the logical context of your code), like so:

str = ""
num = 0

dglienna
December 16th, 2010, 04:18 PM
Why dig up long-dead posts?