Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a DATE variable NULL

Status
Not open for further replies.

mdweezer

Technical User
Jun 15, 2004
56
US
Sorry this is my second post, I hope to make it clearer and to find a answer :(

Using the following line
Code:
GenerationDateValue = Nz(Generation_Date.Value, 0)

If Generation_Date.Value contains nothing at all then the value of GenerationDateValue becomes "12:00:00 AM"

Therefore later on in my code when I do a IsNull(GenerationDateValute) it returns False because it contains "12:00:00 AM" hence screwing up the rest of my code.

Is there any way if my date field is blank, to check to see if its blank, and if it is make it null, or if there is a date to simply copy the date into the field.

It sounds simple but i've been trying to figure it out all morning and its driving me nuts!
 
As a simple work around i'm using:
Code:
If GenerationDateValue <> "12:00:00 AM" And ToDateValue = "12:00:00 AM" Then

To make my code works... it's ugly but it works
 
md,

Why don't you test Generation_Date.Value again INSTEAD of GenerationDateValue, which, by the way, contains ZERO in your example, that you choose to display in the format as "12:00:00 AM"

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
I had to change my way of thinking...

Null is not a value, it is a condition.
I think of a null condition as "I don't know"

Review for more explanation, examples and solutions.

If the table allows Null in GenerationDateValue, then it would seem all you have to do is change:
GenerationDateValue = Nz(Generation_Date.Value, 0)
to:
GenerationDateValue = Generation_Date.Value

It would seem the problem may be that you'd like GenerationDateValue to be blank if not used. If it is a date field, it will not allow a space - but you can tell it to allow null...



HTH,
Bob [morning]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top