Password protected form

  • Thread starter Thread starter Garyj
  • Start date Start date
G

Garyj

Guest
I have a form that I have password protected with the following code. This code works however, when it prompts for the password to be entered into the input box the password shows. How do I get it now to show the actual password just ********* when typing.

Code:
Private Sub Form_Open(Cancel As Integer)

         Dim Hold As Variant
         Dim tmpKey As Long
         Dim I As Integer
         Dim rs As Recordset
         Dim db As Database

         On Error GoTo Error_Handler
         ' Check to see if the user is passing in the Password.
         Hold = InputBox("Please Enter Your Password", "Enter Password")
         ' Open the table that contains the password.
         Set db = CurrentDb
         Set rs = db.OpenRecordset("tblPassword", dbOpenTable)
         rs.Index = "PrimaryKey"
         rs.Seek "=", Me.Name
         If rs.NoMatch Then
            MsgBox "SORRY SYSTEM WAS UNABLE TO LOCATE PASSWORD INFO. PLEASE TRY AGAIN"
            Cancel = -1
         Else
            ' Test to see if the key generated matches the key in
            ' the table; if there is not a match, stop the form
            ' from opening.
            'If Not (rs![KeyCode] = KeyCode(CStr(Hold))) Then
            If Not (CStr(rs![KeyCode]) = Hold) Then
               MsgBox "SORRY YOU HAVE ENTERED AN INCORRECT PASSWORD." & _
                  "PLEASE TRY AGAIN.", vbOKOnly, "INCORRECT PASSWORD"
               Cancel = -1
            End If
         End If
         rs.Close
         db.Close
         Exit Sub

Error_Handler:
         MsgBox Err.DESCRIPTION, vbOKOnly, "Error #" & Err.Number
         Exit Sub
     
End Sub


Thank you in advance
 
Last edited by a moderator:
Change the input mask type of the control to Password.
 
Don't use an input box, use a text box and set the input mask to Password.

David
 
Password Protrect Form

dcx693 said:
Change the input mask type of the control to Password.


In my table I set the input mask to password. I have this code running when the form opens. It does work but I just don't want to see the password show up in the box.
 
Garyj said:
In my table I set the input mask to password. I have this code running when the form opens. It does work but I just don't want to see the password show up in the box.

Not for the table;the properties for the text box.
________
Wholesale vaporizers
 
Last edited:
Last edited:

Users who are viewing this thread

Back
Top Bottom