How to Mask Password Input

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
138
Hi Everyone,

The code below is on a button which opens a table when the password is entered. I need to mask the password
as it is being typed in the dialog box if someone could help me with that please.

Thank you!

Code:
Private Sub Command58_Click()



'Attached to On Click event of cmdOpenDepartmentTable


    Dim strPasswd


    strPasswd = InputBox("Enter Password", "Restricted Form")


    'Check to see if there is any entry made to input box, or if
    'cancel button is pressed. If no entry made then exit sub.


    If strPasswd = "" Or strPasswd = Empty Then
        MsgBox "No Input Provided", vbInformation, "Required Data"
        Exit Sub
    End If


    'If correct password is entered open Departments table
    'If incorrect password entered give message and exit sub


    If strPasswd = "DSR" Then
        DoCmd.OpenTable "Departments", acNormal
        


    Else
        MsgBox "Sorry, you do not have access to this form", _
               vbOKOnly, "Important Information"
        Exit Sub
    End If
End Sub
 
Last edited:

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,594
Office Version
  1. 365
Platform
  1. Windows
That's difficult to do with an Inputbox, you'd be better of using a userform.
You can set the PasswordChar property of a textbox so that it masks the input
 
Last edited:

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,510
Office Version
  1. 365
Platform
  1. Windows
That's difficult to do with an Inputbox, you'd be better of using a userform.
Fluff, are you talking about Excel or Access?
The use of the word "userform" seems to imply you might be talking about Excel, but the question is posted in the Access forum (where the nomenclature would just be "Form").
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,594
Office Version
  1. 365
Platform
  1. Windows
Oops,hadn't noticed this was in the Access forum
 

JonXL

Active Member
Joined
Feb 5, 2018
Messages
357
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have done this in Access with userforms created in VBE.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,462
Messages
5,528,942
Members
409,848
Latest member
Blomsten
Top