I sure I have to put something in this code. If username and password is correct insert username to active cell. Username is textbox1
Public pattempts
Private Sub cmbValidate_Click()
If Trim(TextBox1.Text) = "" Then
MsgBox "Please enter your login", vbCritical, "Login error"
Exit Sub
End If
If Trim(TextBox2.Text) = "" Then
MsgBox "Please enter your password", vbCritical, "Password error"
Exit Sub
End If
Set login = Sheets("User Database").UsedRange.Resize(, 1).Find(TextBox1.Text, , xlValues, xlWhole)
If login Is Nothing Then
pattempts = pattempts + 1
If pattempts = 3 Then Call close_wkb
TextBox3.Text = TextBox3.Text + 1
MsgBox "You have tried " & pattempts & " time and " & IIf(pattempts = 1, 2, 1) & " attempts left", vbInformation, "Validation error"
Exit Sub
End If
Set Password = login.Offset(, 1)
If Password <> TextBox2.Text Then
pattempts = pattempts + 1
If pattempts = 3 Then Call close_wkb
TextBox3.Text = TextBox3.Text + 1
MsgBox "You have tried " & pattempts & " time and " & IIf(pattempts = 1, 2, 1) & " is balance", vbInformation, "Validation error"
Exit Sub
End If
Login_Form.Hide
End Sub
Bookmarks