system date returns null

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

Testing for the year returns a null using the system date. I am using
Access2007. This worked in Access2003.

My code is:

190 If Right(Year(Date), 2) = txtEYear Then txtEYear = ""

When I run the code and check "date" with debug, it shows 'null'.
 
On Sun, 14 Feb 2010 14:21:02 -0800, Dave

That's unusual. Does your code compile? Check a code window > Debug >
Compile.

-Tom.
Microsoft Access MVP
 
Testing for the year returns a null using the system date. I am using
Access2007. This worked in Access2003.

My code is:

190 If Right(Year(Date), 2) = txtEYear Then txtEYear = ""

When I run the code and check "date" with debug, it shows 'null'.

My guess would be that you have a form control and/or a table field named
Date, and Access is getting confused about whether you mean it, or the builtin
function. It's best to avoid reserved words such as Date or Time for Access
objects!

If you insist, try

If Format(DAO.Date, "yy") = txtEYear Then txtEYear = ""

Date() doesn't return a string, but a Date/Time; the Format function will be
better at extracting the two digit year.
 
Back
Top