hi,
i have an excel file which tracks break time. The program works by logging in the start time of break and the log out time of the break of every employee. What I would like to do is to have a prompt if the user immediately logs out at an early time. Say if the user's start time break is 1:00 PM, if he happens to log out immediately, he should be given a prompt that he can only log out after 25 of his total 30 minute breaktime. Thus he can only log out at 1:26 PM.
My code below currently logs in and logs out the time but without the prompt i would like to have.
Sub Endb3()
Dim BreakTime As Integer
Dim Min As String, Sec As String
Dim StartTime As Single
Dim StopTime As Single
Dim TLeft As String
BreakTime = 30 'Break Time in minutes
StartTime = Cells(CurRow, "L").Value
StopTime = StartTime + TimeSerial(0, BreakTime, 0)
'Format the time remaining to show only minutes and seconds remaining
TLeft = Format(StopTime - Time, "hh:mm:ss")
'Ignore the hours
TLeft = Right(TLeft, Len(TLeft) - 3)
'Separate the minutes and seconds
Min = Left(TLeft, 2)
Sec = Right(TLeft, 2)
With Me
If StopTime < 25 Then ' this is where i am missing something i think please help
MsgBox "You may only log out after 25 minutes." & vbCrLf & _
"Please take time to chill out and relax." & vbCrLf & _
"Click OK to proceed.", vbOKOnly + vbExclamation, "Early Log Out."
TextBox1.Value = vbNullString
TextBox1.SetFocus
lblemployee.Caption = ""
lblshift.Caption = ""
lblcoach.Caption = ""
TextBox2.Text = ""
lblinout.Caption = ""
lblmsgbox.Caption = ""
ListBox1.RowSource = vbNullString
ElseIf Time < StopTime Then
lblmsgbox.Caption = "You still have " & Min & " minutes and " & Sec & " seconds remaining. "
Cells(CurRow, "M") = Time
lblinout.Caption = "OUT"
Application.Wait (Time() + CDate("00:00:01"))
ActiveWorkbook.save
TextBox1.Value = vbNullString
TextBox1.SetFocus
lblemployee.Caption = ""
lblshift.Caption = ""
lblcoach.Caption = ""
TextBox2.Text = ""
lblinout.Caption = ""
lblmsgbox.Caption = ""
ListBox1.RowSource = vbNullString
End If
If Time > StopTime Then
lblmsgbox.Caption = "You are " & Min & " minutes and " & Sec & " second overbreak. "
Cells(CurRow, "M") = Time
lblinout.Caption = "OUT"
Application.Wait (Time() + CDate("00:00:01"))
ActiveWorkbook.save
TextBox1.Value = vbNullString
TextBox1.SetFocus
lblemployee.Caption = ""
lblshift.Caption = ""
lblcoach.Caption = ""
TextBox2.Text = ""
lblinout.Caption = ""
lblmsgbox.Caption = ""
ListBox1.RowSource = vbNullString
End If
End With
End Sub
thanks,
stoey
Bookmarks