Need Password Code

  • Thread starter Thread starter George
  • Start date Start date
G

George

I am trying to add password protection to one form in my
database. What I am trying to do is create a form - have
one text field with the input mask set to Password. When
the password I set = the password entered it opens the
required form. If it doesn't = the password entered it
gives error message "Incorrect Password" I don't know how
to write code - but this is what I am guessing it would
look like.


If [mytextfield] = "mypassword" Then
DoCmd.OpenForm "Name of Form I want to protect"
ElseIf [mytextfield] <> "mypassword" Then
MsgBox ("Incorrect Password")
Cancel = True
End If
 
Thanks - Is there a beginners version ?
-----Original Message-----
Here is an example of what you are trying to do.

http://support.microsoft.com/default.aspx?scid=kb;en- us;209871

--
Wayne Morgan
Microsoft Access MVP


George said:
I am trying to add password protection to one form in my
database. What I am trying to do is create a form - have
one text field with the input mask set to Password. When
the password I set = the password entered it opens the
required form. If it doesn't = the password entered it
gives error message "Incorrect Password" I don't know how
to write code - but this is what I am guessing it would
look like.


If [mytextfield] = "mypassword" Then
DoCmd.OpenForm "Name of Form I want to protect"
ElseIf [mytextfield] <> "mypassword" Then
MsgBox ("Incorrect Password")
Cancel = True
End If


.
 
Step 16 does most of it for you. The first part "encrypts" (not very strong encryption)
the password so that someone looking at the table where the password is stored can't read
it. If you want a fixed password, you could hard code it right into your code and you
wouldn't need the table and the code to read/write the password.

--
Wayne Morgan
Microsoft Access MVP


George said:
Thanks - Is there a beginners version ?
-----Original Message-----
Here is an example of what you are trying to do.

http://support.microsoft.com/default.aspx?scid=kb;en- us;209871

--
Wayne Morgan
Microsoft Access MVP


George said:
I am trying to add password protection to one form in my
database. What I am trying to do is create a form - have
one text field with the input mask set to Password. When
the password I set = the password entered it opens the
required form. If it doesn't = the password entered it
gives error message "Incorrect Password" I don't know how
to write code - but this is what I am guessing it would
look like.


If [mytextfield] = "mypassword" Then
DoCmd.OpenForm "Name of Form I want to protect"
ElseIf [mytextfield] <> "mypassword" Then
MsgBox ("Incorrect Password")
Cancel = True
End If


.
 
Back
Top