what to do if date field is Null, but code does not recognize this ACCESS 2010

I have an unbound form where one of the date fields is optional.  However, in the code, it inputs #12:00:00 AM# as the value.  I can't set it to Null nor "" as this is for text.  So, if a date field on a form is optional, how can I text for this in the vba.  If it does not have a value, I want to run one DoCmd, and if it does have a date, run a different DoCmd.
Sandra SmithRetiredAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kelvin SparksCommented:
It seems strange that you cannot use a NULL. A NULL datetime column is quite valid in Access. I can understand a "" as a zero length string would not be a valid value in a datetime, but NULL is.

You would need to ensure that there's no default values set for it



Kelvin
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You should be able to test using Nz:

if Nz(Me.YourTextBox) Then
  '/ run code
Else
  '/ run code
End If
Gustav BrockCIOCommented:
It doesn't input #12:00:00 AM#. That's just the zero value of a date/time variable.

You can check for a date input with IsDate:

If IsDate(Me!txtDate.Value) Then
    ' Do something.
Else
    ' Do something else.
End If

/gustav

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rey Obrero (Capricorn1)Commented:
you can also use

if me.textbox & ""="" then
  'run code for no date value
  else
 'run code with date value
end if
Sandra SmithRetiredAuthor Commented:
Checking for date worked, I could not get anything related to text strings to do what I wanted, but this seems, so far, to run.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.