Hi,
I have a time tracker program which works this way. I have a Userform which has 2 textboxes. User enter his employee id on textbox1 then enters a valid break time code which are 1,2 and 3 on textbox2. If User typed 1 then first breaktime start time will be pasted on the worksheet. When User returns after break he then enters his employee id again and then type 1 to end his first breaktime, the end time will be pasted on the worksheet. My program works fine however, I am trying to place a code which will prompt the user to end his first break time before entering another valid break code. Kindly check my code below as I am receiving an error message. 'Run-time error 9' Subscript out of range. This thing is driving me nuts. Any advise or can you tweak my coding vba experts? Thanks
Private Sub TextBox2_Change()
Dim break1 As Integer
Dim break2 As Integer
Dim break3 As Integer
break1 = 1
break2 = 2
break3 = 3
If TextBox2.Value = 1 Then
If IsEmpty(Cells(CurRow, "F")) Then
Call Startb1
ElseIf Not IsEmpty(Cells(CurRow, "F")) Then
MsgBox "You need to end your first breaktime before entering another break code"
ElseIf IsEmpty(Cells(CurRow, "G")) Then
Call Endb1
Else: MsgBox "You have already taken this 30 MINUTES break time.", vbExclamation + vbOKOnly, "Comsumed Break"
TextBox2.Text = ""
End If
End If
If TextBox2.Value = 2 Then
If IsEmpty(Cells(CurRow, "I")) Then
Call Startb2
ElseIf Not IsEmpty(Cells(CurRow, "I")) Then
MsgBox "You need to end your second breaktime before entering another break code"
ElseIf IsEmpty(Cells(CurRow, "J")) Then
Call Endb2
Else: MsgBox "You have already taken this 15 MINUTES break time.", vbExclamation + vbOKOnly, "Comsumed Break"
TextBox2.Text = ""
End If
End If
If TextBox2.Value = 3 Then
If IsEmpty(Cells(CurRow, "L")) Then
Call Startb3
ElseIf Not IsEmpty(Cells(CurRow, "L")) Then
sgBox "You need to end your third breaktime before entering another break code"
ElseIf IsEmpty(Cells(CurRow, "M")) Then
Call Endb3
Else: MsgBox "You have already taken this 30 MINUTES break time.", vbExclamation + vbOKOnly, "Comsumed Break"
TextBox2.Text = ""
End If
End If
End Sub
Regards,
Brad
Bookmarks