View Full Version : Validation rule for text


bob786
04-14-2010, 01:38 PM
Hello everyone, this is my first thread and post.

Basically i want to limit the character size in a table.

E.G Field name- First name and data type-Text

I want to limit the character size of the first name so the minimum is 4 characters and up to 10 characters max in length.

I been trying to figure it out but no luck.

Any help would be much appreciated.:(:o:o

pbaldy
04-14-2010, 01:49 PM
I hope nobody has a short name like "Bob"! ;)

This should work:

Len([FirstName])>3 And Len([FirstName])<11

You could use the Field Size property to define the upper limit.

bob786
04-14-2010, 01:52 PM
Hi thanks for a quick reply, but it doesnt seem to work, it says the following:

Could not find the field name "FirstName"...?

dont know what is going on, btw im using access 2007..

bob786
04-14-2010, 01:55 PM
Edit.. OMG IT WORKS argh yay, i needed to leave space between first and name and now it works, thanks.

I have another issue, what if i want to have a rule for only accepting text and not numeric in text data type? is that possible..?

pbaldy
04-14-2010, 02:05 PM
You'll find in time that spaces in your object names aren't worth the trouble. I'd change it if it's not too late.

You'll find some handy validation rules here:

http://allenbrowne.com/ValidationRule.html

pbaldy
04-14-2010, 02:09 PM
By the way, welcome to the site!

bob786
04-14-2010, 02:12 PM
Thanks pbaldy, the link works like a charm, it is very useful. thanks once again.

pbaldy
04-14-2010, 02:24 PM
No problemo. You'll find a lot of good info on Allen's site.

bob786
04-14-2010, 02:34 PM
Do you a validation rule that only allows you to input a text OR a numeric in one field. such as house name/ number, but not both...

pbaldy
04-14-2010, 02:42 PM
If I understand correctly, combining Allen's appears to work:

Is Null Or Not Like "*[!a-z]*" Or Not Like "*[!0-9]*"

That let's me do all letters or all numbers, but no combinations.

bob786
04-14-2010, 02:48 PM
Thanks it does work, I tried Allens E-mail rule and it works really well. Must thank you as you helped me alot in fews mins.

pbaldy
04-14-2010, 03:03 PM
Happy to help; good luck on the project.