Hi,
My VB Code is not working.
What I am trying to do is this:
enter a Clock number(clocknumberbox) and password (passwordbox) on a form and if the password found on sheetTeam (C1) matches up to the CLOCKNUMBER SheetTeam (B1) clicking on the Log In command button will open another form named DataEntryForm
Private Sub cmdLogIn_Click()
‘data that is entered in the Entrance Form will search if clock number cell range b entered equals adjacent cell password looping as required
Dim Clock_Number As Integer
Dim Password As String
Dim Year As Integer
Clock_Number = SheetTeam.Range("B1").Value
Password = SheetTeam.Range("C1").Value
Dim c, rng As Range
Dim strclocknumber, strpassword As String
Dim shtTeam As Collection
Dim bFound As Boolean
Set shtEntry = ThisWorkbook.Sheets("Team") 'or wherever they are entering UN/PW
Set shtData = ThisWorkbook.Sheets("Team") 'or whatever sheet contains pws
Set rng = shtTeam("B:B")
bFound = False
strclocknumber = shtEntry.Range("N2") 'or wherever
strpassword = shtEntry.Range("O2") 'or wherever
For Each c In rng
If StrComp(c, strclocknumber, vbTextCompare) = 0 And _
StrComp(c.Offset(0, 1), strpassword, vbBinaryCompare) = 0 Then
DataEntryForm.Show
bFound = True
Exit For
End If
Next c
If bFound = False Then MsgBox "Incorrect User Name or Password"
My VB Code is not working.
What I am trying to do is this:
enter a Clock number(clocknumberbox) and password (passwordbox) on a form and if the password found on sheetTeam (C1) matches up to the CLOCKNUMBER SheetTeam (B1) clicking on the Log In command button will open another form named DataEntryForm
Private Sub cmdLogIn_Click()
‘data that is entered in the Entrance Form will search if clock number cell range b entered equals adjacent cell password looping as required
Dim Clock_Number As Integer
Dim Password As String
Dim Year As Integer
Clock_Number = SheetTeam.Range("B1").Value
Password = SheetTeam.Range("C1").Value
Dim c, rng As Range
Dim strclocknumber, strpassword As String
Dim shtTeam As Collection
Dim bFound As Boolean
Set shtEntry = ThisWorkbook.Sheets("Team") 'or wherever they are entering UN/PW
Set shtData = ThisWorkbook.Sheets("Team") 'or whatever sheet contains pws
Set rng = shtTeam("B:B")
bFound = False
strclocknumber = shtEntry.Range("N2") 'or wherever
strpassword = shtEntry.Range("O2") 'or wherever
For Each c In rng
If StrComp(c, strclocknumber, vbTextCompare) = 0 And _
StrComp(c.Offset(0, 1), strpassword, vbBinaryCompare) = 0 Then
DataEntryForm.Show
bFound = True
Exit For
End If
Next c
If bFound = False Then MsgBox "Incorrect User Name or Password"