Help! Password Protected Form to mask the enter password w/ aster

G

Guest

Hi, Help!!

I have created a password protected form that allows me to:

if correct password is entered, a restricted form will then be open;
otherwise, it will say "incorrect password".

Now, I don't want to show the password when user enters in the unbounded
field of the form (shows as *******). I know input mask to select Password
is a good one. But when I try to read it from Visio, it can only read
"*******" but not the stored password as I want to.

Can anybody help? It is urgent.....


Thanks.
 
D

Dale Fye

ML,

Here is the way I would do it.

1. Create a text box (txt_HiddenPwd) on the form and set its visible
property to False

2. In the KeyPress event of the text box you are using to enter the
password (we'll call it txt_Password), enter the following code.

Private Sub txt_Password_KeyPress(KeyAscii As Integer)

If KeyAscii > 32 And KeyAscii < 127 Then
Me.txt_HiddenPassword = Me.txt_HiddenPassword & Chr$(KeyAscii)
Me.Repaint
KeyAscii = 42
Else
KeyAscii = 0
End If

End Sub

Then reference the value in txt_HiddenPassword when the press the command
button to login.

HTH
Dale
 
G

Guest

Hi Dale,
How can I reference the value in txt_HiddenPassword when the press the
command button to login?

Thanks,
ML
 
D

Dale Fye

The way I have done it in the past is to have a table in the database which
contains your userids and passwords. Lets call it tbl_Passwords. It should
contain fields [Login] and [Password] in order for the code below to work.
Keep in mind, that this is not a very secure way to secure your database,
but it will keep the person that has no knowledge of Access out of the
database at least for a little while. If you need a more secure database,
consider implementing Access security.

The user enters his/her userid into a Login text box on the form, then
enters his/her password in the password textbox.

In the Click event of your login command button, you need to check to see
whether the combination of userid and password exist in the passwords table.
Something like:

Private cmd_Login_Click()

Dim strCriteria as string
If Len(me.txt_Login & "") = 0 Then
msgbox "You must enter your userid in the login box!"
me.txt_Login.setfocus
Exit Sub
elseif LEN(me.txt_HiddenPassword & "") = 0 then
msgbox "You must enter your password in the password box!"
me.txt_Password.setfocus
Exit Sub
Endif

strCriteria = "[Login] = " & chr$(34) & me.txt_Login & chr$(34) & " AND
" _
& "[Password] = " & chr$(34) & me.txt_HiddenPassword &
chr$(34)
If isnull(DLOOKUP("Password", "tbl_Passwords", strCriteria)) then
msgbox "Invalid password. Please try again!"
Exit Sub
Else
Docmd.OpenForm "yourMainForm"
Docmd.close acform, frm_Login
Endif

End Sub

HTH
Dale
 

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