userform password

glockster

Board Regular
Joined
Mar 24, 2002
Messages
181
I have a userform with a combobox containing 3 names, followed by a textbox (with the passwordchar set w/ a "*"), and a command button. Using all code, how can I have the program close or prompt to re-enter password, if a person enters a wrong password (a different password required for each name).
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try the following:

Private Sub CommandButton1_Click()
If ComboBox1.Value = FirstUser Then
If TextBox1.Value = FirstUserPassword Then
Call YourNextMacro
Else: MsgBox "Wrong Password, Re-enter"
End If
ElseIf ComboBox1.Value = SecondUser Then
If TextBox1.Value = SecondUserPassword Then
Call YourNextMacro
Else: MsgBox "Wrong Password, Re-enter"
End If
ElseIf ComboBox1.Value = ThirdUser Then
If TextBox1.Value = ThirdUserPassword Then
Call YourNextMacro
Else: MsgBox "Wrong Password, Re-enter"
End If
End If
End Sub

Code assumes you have combobox1, textbox1, and commandbutton1. Edit it to fit your needs. (I didn't check to see if it works, so post if you have problems).
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,027
Members
448,543
Latest member
MartinLarkin

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