Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation on text length

Status
Not open for further replies.

micang

Technical User
Aug 9, 2006
626
US
Access 2003:

Hi All,

I have a text field in a table that can only have a maximun of 25 characters - including spaces.

I have set the field size to 25, but how do I go about setting a validation so that if a user tries to type in a length longer than 25, then a error message will pop up.

I tried putting len<25 in Validation Rule and then a message in validation Text, but this does not do it.

Any help would be appreciated.

Michael
 
Set the Validation Rule to
Len([txtYourControlName])<=25

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Hi Duane,

Thanks for the input.

I am new to this, am I correct in saying that this has to be done on a form or page? i.e. the control has to be set-up at form level?

Michael
 
I generally don't edit data directly in a table so the solution I suggested was tested in a form control. You could set this up in a field definition like:
Len([YourUnnamedField])<=25

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks for your input and help Duane, will give this a go.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top