Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Posts
    300

    Question Unanswered: How to hide typed password?

    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????

  2. #2
    Join Date
    Feb 2004
    Posts
    137
    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:
    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:
    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.

  3. #3
    Join Date
    Feb 2004
    Posts
    137
    Actually the code in frmPassword should be:
    Code:
    Private Sub cmdOK()
    
    If Me.txtPassword = "password" Then
        MsgBox "GOOD"
        Me.Visible = False
    Else
        MsgBox "SORRY"
        DoCmd.Close
    End If
    
    End Sub

  4. #4
    Join Date
    Feb 2004
    Location
    Colorado state
    Posts
    65
    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
    Attached Files Attached Files

  5. #5
    Join Date
    Nov 2003
    Posts
    300
    Thanks - It works great!

  6. #6
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Quote Originally Posted by databasemon
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •