Mask Input box text from a command button in a userform

ReignEternal

New Member
Joined
Apr 11, 2021
Messages
34
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
 

GWteB

Well-known Member
Joined
Sep 10, 2010
Messages
2,769
Office Version
  1. 2013
Platform
  1. Windows
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.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

ReignEternal

New Member
Joined
Apr 11, 2021
Messages
34
Office Version
  1. 365
Platform
  1. Windows
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.
 

ReignEternal

New Member
Joined
Apr 11, 2021
Messages
34
Office Version
  1. 365
Platform
  1. Windows
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.
 

GWteB

Well-known Member
Joined
Sep 10, 2010
Messages
2,769
Office Version
  1. 2013
Platform
  1. Windows
Well done and thanks for the follow-up (y)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,477
Messages
5,831,909
Members
430,090
Latest member
bjonesh2o

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
Top