Validation Rule - must have at least 1 number and 1 letter

K

kishan

Hi, i have a table where passwords are kept and i need a vaidation rule that
means the password must have at least one letter and one number. Also woud it
be easier to have the coding on a form or in the validation option in the
table design (i would prefer not to have a form for this table so can the
coding go in the validation rule box in the table design).

thanks
kishan
 
K

Ken Snell [MVP]

One should not enter data directly into the table. Use a form for that
purpose!

That noted, where you use the Validation Rule sometimes is a matter of
preference; other times, it's a matter of where it's easier to
write/test/handle the validation. If you put the Validation Rule in the
table, ACCESS will generate an error message that may or may not be
meaningful to your user; a similar situation occurs if you use the
Validation Rule for a control on a form. If you want to control the message
that is displayed, you need to use the Form's Error event to trap the
specific error for the specific control and substitute your own message. Or
use the control's AfterUpdate or BeforeUpdate event (or the form's
BeforeUpdate event) to capture the error.

A validation rule that says you must have a letter and number (assuming
either can be "first" in the string's contents):
Like "*[0-9]*[a-z]" Or Like "*[a-z]*[0-9]*"
 
D

david epsom dot com dot au

write/test/handle the validation. If you put the Validation Rule table,
ACCESS will generate an error message that may or may not
meaningful to your user; a similar situation occurs if you use

There is a matching 'Validation Text' property.
('The error message that appears when you enter a value prohibited by the
validation rule')

(david)


Ken Snell said:
One should not enter data directly into the table. Use a form for that
purpose!

That noted, where you use the Validation Rule sometimes is a matter of
preference; other times, it's a matter of where it's easier to
write/test/handle the validation. If you put the Validation Rule in the
table, ACCESS will generate an error message that may or may not be
meaningful to your user; a similar situation occurs if you use the
Validation Rule for a control on a form. If you want to control the
message that is displayed, you need to use the Form's Error event to trap
the specific error for the specific control and substitute your own
message. Or use the control's AfterUpdate or BeforeUpdate event (or the
form's BeforeUpdate event) to capture the error.

A validation rule that says you must have a letter and number (assuming
either can be "first" in the string's contents):
Like "*[0-9]*[a-z]" Or Like "*[a-z]*[0-9]*"

--

Ken Snell
<MS ACCESS MVP>


kishan said:
Hi, i have a table where passwords are kept and i need a vaidation rule
that
means the password must have at least one letter and one number. Also
woud it
be easier to have the coding on a form or in the validation option in the
table design (i would prefer not to have a form for this table so can the
coding go in the validation rule box in the table design).

thanks
kishan
 
K

Ken Snell [MVP]

This is true... I so rarely use the table's validation rule that I
overlooked it in my "memory search". I was thinking of the standard error
message generated in the form's error event.

Thanks, david.

--

Ken Snell
<MS ACCESS MVP>

david epsom dot com dot au said:
write/test/handle the validation. If you put the Validation Rule table,
ACCESS will generate an error message that may or may not
meaningful to your user; a similar situation occurs if you use

There is a matching 'Validation Text' property.
('The error message that appears when you enter a value prohibited by the
validation rule')

(david)


Ken Snell said:
One should not enter data directly into the table. Use a form for that
purpose!

That noted, where you use the Validation Rule sometimes is a matter of
preference; other times, it's a matter of where it's easier to
write/test/handle the validation. If you put the Validation Rule in the
table, ACCESS will generate an error message that may or may not be
meaningful to your user; a similar situation occurs if you use the
Validation Rule for a control on a form. If you want to control the
message that is displayed, you need to use the Form's Error event to trap
the specific error for the specific control and substitute your own
message. Or use the control's AfterUpdate or BeforeUpdate event (or the
form's BeforeUpdate event) to capture the error.

A validation rule that says you must have a letter and number (assuming
either can be "first" in the string's contents):
Like "*[0-9]*[a-z]" Or Like "*[a-z]*[0-9]*"

--

Ken Snell
<MS ACCESS MVP>


kishan said:
Hi, i have a table where passwords are kept and i need a vaidation rule
that
means the password must have at least one letter and one number. Also
woud it
be easier to have the coding on a form or in the validation option in
the
table design (i would prefer not to have a form for this table so can
the
coding go in the validation rule box in the table design).

thanks
kishan
 

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