Results 1 to 8 of 8

Prompt early log out time using msgbox

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-07-2008
    Location
    United States
    MS-Off Ver
    Microsoft Office 2003
    Posts
    362

    Prompt early log out time using msgbox

    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
    Last edited by stoey; 01-21-2009 at 05:43 AM. Reason: change title

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1