[INDENT]I have an amended code as seen below. However I am trying to add an error message if the ComBox1 is blank. (like the DropDownName). I really don't know how to add it without getting IF, DO type messages...can anyone see the error of my ways????
PS the...... Strp = "Punched in at " & Now
MsgBox (Strp)
....does not need to be in code if causes a problem.
Thanks, Yorkie
Private Sub ComboBox1_Change()
End Sub
Private Sub NameDropDown_Change()
End Sub
Private Sub PasswordTextBox_Change()
End Sub
Private Sub PunchIn_Click()
'This is the sub to record the time when punching in. It records the data on the "Data Sheet" Sheet
'The "Data Sheet" sheet also has the usernames and passwords of the users
Dim Counter As Double
Dim Strp As String
Dim Found As Boolean
Dim strPassword As String
Me.Hide
strPassword = PasswordTextBox.Text
strPassword = StrConv(strPassword, vbLowerCase)
'Find their Username on the List
Counter = 0
Found = False
Do Until Found = True
Counter = Counter + 1
If Sheets("Data Sheet").Range("Table1[[#Headers],[Names]]").Offset(Counter, 0) = NameDropDown.Text Then
Found = True
End If
'Error if the name is not on the list
If Sheets("Data Sheet").Range("Table1[[#Headers],[Names]]").Offset(Counter, 0) = "" Then
MsgBox ("Name is not in list. Please Select a name from the dropdown menu or add your name to the list.")
Unload Me
Call ShowPunchIn
Exit Sub
End If
Loop
'Check to see if password matches
If Sheets("Data Sheet").Range("Table1[[#Headers],[Names]]").Offset(Counter, 1) = strPassword Then
Found = False
Counter = 1
Do Until Found = True
'Enter in the time and save
If Sheets("Data Sheet").Range("b2").Offset(Counter, 0) = "" Then
Sheets("Data Sheet").Range("b2").Offset(Counter, 0).NumberFormat = "@"
Sheets("Data Sheet").Range("b2").Offset(Counter, 0) = NameDropDown.Text
Sheets("Data Sheet").Range("b2").Offset(Counter, 1) = Now
Sheets("Data Sheet").Range("b2").Offset(Counter, 4) = NameDropDown.Text
Found = True
Strp = "Punched in at " & Now
MsgBox (Strp)
ActiveWorkbook.Save
Else
'If there is an error, then notify
If Sheets("Data Sheet").Range("b2").Offset(Counter, 0) = NameDropDown.Text Then
If Sheets("Data Sheet").Range("b2").Offset(Counter, 2) = "" Then
MsgBox ("You May Have Not Clocked Out. Please Talk to Your Supervisor to Fix the Error.")
Found = True
Unload Me
Call ShowPunchIn
Exit Sub
End If
End If
End If
Counter = Counter + 1
Loop
Else: MsgBox ("Incorrect Password")
End If
Unload Me
End Sub [/INDENT]