How to validate 4 digit year or "Present" in Access table

G

Guest

In Access how do I validate data entered as either a four digit year (such as
2002) or the word "Present"?

I created the validation rule ">1900 and <2025 or "Present" and tried to
enter data. The field accepted 4 digits fine, but when I tried to enter the
word 'Present' I get the following message:

"Error 'Error evaluating CHECK constraint.' in the validation rule"

I get the same message with the rule ">1900 and <2025 or ="Present"
 
R

Rick B

Is this a number field or a text field? You can't use ">1900 and <2025 " to
evaluate a text field and you can't use "="Present"" in a number field.

Rick B
 
B

Brendan Reynolds

If you want the user to be able to enter the word 'Present' then the field
will have to be a text field, in which case the validation rule would need
to be >"1900" And <"2025" Or "Present"

Note the quotes around the 'numbers'.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
G

Guest

Actually, I can use ">1900 and <2025" to evaluate a text field. It was
working just fine. It doesn't verify the numeric value, just the character
value; that's fine.

Then some of my users said "I'm still in that position. I need to be able
to enter the word "Present". Hence my dilemma.
 
G

Guest

Thank you Brendan. That works fine.

Brendan Reynolds said:
If you want the user to be able to enter the word 'Present' then the field
will have to be a text field, in which case the validation rule would need
to be >"1900" And <"2025" Or "Present"

Note the quotes around the 'numbers'.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
G

Guest

Thanks for your help Rick. You go me to thinking. I changed my validation
rule bu putting quotation marks around the digits so that Access would know
that they're text. It's now working just fine.
 

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