Setting A Password Rule For A Field

C

Chipcom

Hi

I need to know how to set a rule to a password field that the user
only be able to type english letters and numbers .

Any idea how?


Thanks
 
E

Eric Blitzer

I got this from a previous post from HTH

Try this code in the BeforeUpdate event of the checkbox:

(untested)

if inputbox ("enter password") <> "s3cr3t" then
me.undo
cancel = true
endif

If you get tired of repeatedly entering the password, try this:

static bOK as boolean
if not bOK then
if inputbox ("enter password") = "s3cr3t" then
bOK = true
else
me.undo
cancel = true
endif


Good Luck
 
P

Peter Hibbs

Paste the following code into the KeyPress event of your text box so
that it looks like this :-

Private Sub YourFieldName_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Like "[!0-9A-Z]" And _
KeyAscii <> vbKeyBack Then KeyAscii = 0
End Sub

Change the word YourFieldName for the name of your text field.

This allows the user to press keys 0 to 9 and A to Z and the BackSpace
key only.

HTH

Peter Hibbs.
 
Top