This code is for a password useform that pops upupon opening a workbook.
Private Sub CommandButtonpassword1_Click()
Static intcount As Integer
Dim strpassword As String
Dim strpasswordmatch As String
intcount = intcount + 1
If intcount > 2 Then
intcount = 0
MsgBox "You Are Not Authorized To Use This Program! Please Contact Your System Administrator For Access!", vbCritical, "Unknown User"
ActiveWorkbook.Close
Exit Sub
End If
passwordcheck
End Sub
Sub passwordcheck()
strpassword = frmpassword1.textboxpassword1.Value
strpasswordmatch = Sheets("Valid Users").Range("c2").Value
If strpassword = strpasswordmatch Then
frmpassword1.Hide
Else
frmpassword1.textboxpassword1.Value = ""
MsgBox "I'm Sorry, That Password Is Incorrect. Please Try Again!", vbCritical, "Invalid Password!"
frmpassword1.textboxpassword1.SetFocus
End If
End Sub
This works great if I manualy set passwordcheck. Example:
passwordcheck = "123456"
but if I have it try to use the value of cell c2 on the valid users page, it doesn;t work. what am I doing wronge?
Private Sub CommandButtonpassword1_Click()
Static intcount As Integer
Dim strpassword As String
Dim strpasswordmatch As String
intcount = intcount + 1
If intcount > 2 Then
intcount = 0
MsgBox "You Are Not Authorized To Use This Program! Please Contact Your System Administrator For Access!", vbCritical, "Unknown User"
ActiveWorkbook.Close
Exit Sub
End If
passwordcheck
End Sub
Sub passwordcheck()
strpassword = frmpassword1.textboxpassword1.Value
strpasswordmatch = Sheets("Valid Users").Range("c2").Value
If strpassword = strpasswordmatch Then
frmpassword1.Hide
Else
frmpassword1.textboxpassword1.Value = ""
MsgBox "I'm Sorry, That Password Is Incorrect. Please Try Again!", vbCritical, "Invalid Password!"
frmpassword1.textboxpassword1.SetFocus
End If
End Sub
This works great if I manualy set passwordcheck. Example:
passwordcheck = "123456"
but if I have it try to use the value of cell c2 on the valid users page, it doesn;t work. what am I doing wronge?