Tags: access, below, cancel, code, database, dim, form, form_open, hide, integer, microsoft, mysql, oracle, password, private, protected, pwd, sql, stringpwd, sub, typed

How to hide typed password?

On Database » Microsoft Access

2,498 words with 5 Comments; publish: Wed, 05 Dec 2007 06:13:00 GMT; (250109.38, « »)

I have a form that is protected with a password ON OPEN, using the code below:

Private Sub Form_Open(Cancel As Integer)

Dim pwd As String

pwd = InputBox("What is the password?")

If pwd = "password" Then

MsgBox "GOOD"

Else

MsgBox "SORRY"

DoCmd.Close

End If

End Sub

How to I "hide" what the user types, like with xxxx instead of the word "password" coming up on the screen??

All Comments

Leave a comment...

  • 5 Comments
    • You can't password-mask an InputBox in Access. What you would need is to create a new form, as a Dialogue Box with at least two controls: a textbox with a password input mask, and a command button to allow the form to open.

      For example, let's say your main for that you want to protect is named Form1:

      Create a form named frmPassword with a textbox control named txtPassword and with the Input Mask property set to Password, and a Command button named cmdOK. Set the form's Popup and Modal properties to Yes.

      In the Code Module for frmPassword, enter the following code:

      Private Sub cmdOK()

      If PWD = "password" Then

      MsgBox "GOOD"

      Me.Visible = False

      Else

      MsgBox "SORRY"

      DoCmd.Close

      End If

      End Sub

      In the Code Module for Form1, enter the following code:

      Private Sub Form_Open(Cancel As Integer)

      DoCmd.OpenForm "frmPassword", , , , , acDialog

      If SysCmd(acSysCmdGetObjectState, acForm, "frmPassword") Then

      If Forms("frmPassword").CurrentView Then

      DoCmd.Close acForm, "frmPassword"

      End If

      Else

      Cancel = True

      End If

      End Sub

      See if this works for you.

      #1; Tue, 11 Dec 2007 20:14:00 GMT
    • Actually the code in frmPassword should be:

      Private Sub cmdOK()

      If Me.txtPassword = "password" Then

      MsgBox "GOOD"

      Me.Visible = False

      Else

      MsgBox "SORRY"

      DoCmd.Close

      End If

      End Sub

      #2; Tue, 11 Dec 2007 20:15:00 GMT
    • Hi

      I can't remember where I got this login, I think I got it from dbforums from the early years posts. I am not trying to claim someone elses work. This does work for me and meets your requirements.

      Mike

      #3; Tue, 11 Dec 2007 20:16:00 GMT
    • Thanks - It works great!
      #4; Tue, 11 Dec 2007 20:17:00 GMT
    • Thanks - It works great!

      What I did in my form was simply go to Form / DesignView, select the Password field and then to that fields properties. There I set the InputMask to Password and that is all it took. Didn't take any coding of any type. Just giving my take on this.

      have a nice one,

      Bud

      #5; Tue, 11 Dec 2007 20:18:00 GMT