system date returns null

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'.
 
T

Tom van Stiphout

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
 
J

John W. Vinson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top