![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Connecticut
Posts: 179
|
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).
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
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).
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Connecticut
Posts: 179
|
That looks like what I'm looking for, thank you very much Al.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|