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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS ACCESS HELP! I'm not sure how to write expression. 2

Status
Not open for further replies.

atxross

MIS
Aug 19, 2002
132
0
0
US
Windows 2000, with Access 2000.

I would like to set a limit on characters for a field in my database to be no more than 5 and no less than 5 characters. This field is also my primary key. If I'm in Design view of the table, how can I write my expression to accept this reference?

Thanks ahead of time to all
 
You want to do 3 things to force this and make it as easy to understand to the user as possible

1.)
set the Field Size property to 5 - This will limit the field size to 5 characters but it will NOT check whether the user is inputting 5 characters however it will ultimately reduce the size of your database.

2.)
set the Validation = Len([FieldName]) = 5 This will force the user to put in exactly 5 characters no more no less.

3.)
set the Validation text = "Your message here" ex. ("You must enter 5 characters. Please re-enter)
 
Or set the field size to 5 as above and then for an input mask put

LLLLL this means a letter must be entered.
or
AAAAA this means a letter or number must be entered.

Input mask characters;

0 User must enter a number between 0 and 9
9 User can enter a number or a space, but entry is not required
# User can enter a number or a space. Entry not required, all blanks converted to space.
L User must enter a letter.
? User can enter a letter, but not required.
A user must enter either a letter or number.
a User can enter a letter or number but entry not required.
& User must enter a character or a space.
C User can enter a character or a space, but entry not required.
< Any letter that follows is converted to lowercase.
> Any letter that follows is converted to uppercase.

Neil
 
Input masks are good except for the fact they do not give a very good explanation to the user if you do not enter in the required number of characters. With the Validation rule, you can insert your own message easily.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top