brayleyboy
Board Regular
- Joined
- Nov 24, 2005
- Messages
- 52
Hi, I am using a userform to create a user login and have what is probably a vey simple question.
I have a combobox that lists the usernames (DBS!V8:10) and have the following code to set a password depending on which username is selected.
I then have a text box (textbox1) to input the password in and a command button to check the password against the username and either allow access or inform the user of an incorrect password (see code below).
Can you tell me if/how I can reference the password declared in the first bit of code in the second bit in place of the question marks?
Many Thanks
Dave[/code]
I have a combobox that lists the usernames (DBS!V8:10) and have the following code to set a password depending on which username is selected.
Code:
Private Sub ComboBox1_Change()
Dim pword As String
If UserForm1.ComboBox1.Value = "DBS!V8" Then
pword = "password1"
End If
If UserForm1.ComboBox1.Value = "DBS!V9" Then
pword = "Password2"
End If
If UserForm1.ComboBox1.Value = "DBS!V10" Then
pword = "Password3"
End If
End Sub
I then have a text box (textbox1) to input the password in and a command button to check the password against the username and either allow access or inform the user of an incorrect password (see code below).
Code:
Private Sub CommandButton1_Click()
If UserForm1.TextBox2.Value <> "????????" Then
MsgBox "Password Incorrect"
Exit Sub
Else
MsgBox "Access Granted"
End If
Unload UserForm1
End Sub
Can you tell me if/how I can reference the password declared in the first bit of code in the second bit in place of the question marks?
Many Thanks
Dave[/code]