How do you set a validation rule?

muppetmad

Registered User.
Local time
Today, 21:30
Joined
Sep 29, 2003
Messages
42
How do I set the field so that you can only enter one of 3 specific letters?
 
I'm sure one of the more expert bods on the forum knows of a more efficient way, but in case you don't get any quick replies, either of the following should work.

1) Make the field a list or combo box and limit the contents to just those three letters.

or

2) In the After Update event of the field, put a check on the entered value to see if your required letter is present e.g. Instr(field,"A") <> 0. You would have three If...elseif clauses, one for each letter. if none are present, return focus back to the field and clear it so the user can enter another. You would also need a check to see if the field's value has a length of 1, to ensure that ONLY the required letter is present.

There are probably a number of other ways to do this, but hopefully this will help.
 
Hi,

If you want to create a sql server constraint, then use the following code as reference



CREATE TABLE cust_sample
(
cust_id int PRIMARY KEY,
cust_name char(50),
cust_address char(50),
cust_credit_limit money,
CONSTRAINT chk_name CHECK (cust_name = 'c' or cust_name = 'd')
)


But as per the previous post this may be better dealt with in the front end
 

Users who are viewing this thread

Back
Top Bottom