Mask Input box text from a command button in a userform

ReignEternal

New Member
Joined
Apr 11, 2021
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a UserForm that I have a button that will delete a line item (after a line item is selected and then the delete button is pressed) that is password protected. This works just fine but when the password is entered, users can see the password. I would like to have the field masked. The lines in bold are the issue I am having. I've been reading through some of the forums here but they are suggesting to create a user form. Can i create a user form within a user form? Here is the most recent thread I was reading (VBA password request before sub starts)

VBA Code:
Private Sub cmdDelete_Click()

    If Selected_List = 0 Then
    
        MsgBox "No row has been selected for deletion!", vbOKOnly + vbInformation, "Edit"
        
        Exit Sub
    
    End If
    
[COLOR=rgb(0, 0, 0)][B]    Dim ans As String[/B][/COLOR]
[B][COLOR=rgb(0, 0, 0)]    ans = InputBox("Please Enter Password to Allow Deletion of Line Item!")
    [/COLOR][/B]
[COLOR=rgb(0, 0, 0)][B]    If ans = "BidSizzle" Then[/B][/COLOR]
    
        Dim iRow As Long
        
        If Selected_List = 0 Then
        
            MsgBox "No row is selected.", vbOKOnly + vbInformation, "Delete"
            Exit Sub
        End If
        
        Dim i As VbMsgBoxResult
        
        i = MsgBox("Do you want to delete the selected record?", vbYesNo + vbQuestion, "Confirmation")
        
        If i = vbNo Then Exit Sub
        
        iRow = Application.WorksheetFunction.Match(Me.lstDatabase.List(Me.lstDatabase.ListIndex, 0), _
        ThisWorkbook.Sheets("Database").Range("A:A"), 0)
        
        Worksheets("Database").Unprotect "GoldStar"
        
        ThisWorkbook.Sheets("Database").Rows(iRow).Delete
        
        Worksheets("Database").Protect "GoldStar"
        
        Call Reset
        
        MsgBox "Selected record has been deleted!", vbOKOnly + vbInformation, "Deleted"
    
    End If
    
End Sub
 
Okay, I see ...
Within the VBE > menu > Insert > Userform
A userform template opens, along with a toolbox dialog to provide the userform with some controls.
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
GWteB, I am such a ditz. All this time I was thinking you were calling my userform userform1 when in fact you were advising me to create a 2nd useform which for demonstration purposes you were calling userform1. This all makes sense now. I am so sorry I didn't realize this from the beginning.
1639374942572.png


Now I just need to work on an error message for when incorrect passwords have been entered.
 
Upvote 0
GWteB, I am such a ditz. All this time I was thinking you were calling my userform userform1 when in fact you were advising me to create a 2nd useform which for demonstration purposes you were calling userform1. This all makes sense now. I am so sorry I didn't realize this from the beginning.
View attachment 53224

Now I just need to work on an error message for when incorrect passwords have been entered.
Ha ha.. i added an else statement if the password is incorrect and bam... now if a wrong password is entered a warning message gets displayed.
 
Upvote 0
Well done and thanks for the follow-up (y)
 
Upvote 0

Forum statistics

Threads
1,214,896
Messages
6,122,132
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top