Please help me with coding for time out portion. I need to code it so it would find and match value for Job Id and EmployID and time out..... Also need multiple session for identical Job ID and employID.
Option Explicit
Private Sub cmdTimein_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("JobTime")
'''find first empty row in database
''iRow = ws.Cells(Rows.Count, 1) _
'' .End(xlUp).Offset(1, 0).Row
'revised code to avoid problems with Excel tables in newer versions
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a part number
If Trim(Me.EmpID.Value) = "" Then
Me.EmpID.SetFocus
MsgBox "Please enter a Employee ID"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.EmpID.Value
ws.Cells(iRow, 2).Value = Me.JobNo.Value
ws.Cells(iRow, 3).Value = Now
ws.Cells(iRow, 6).Value = Date
'clear the data
Me.EmpID.Value = ""
Me.JobNo.Value = ""
Me.EmpID.SetFocus
End Sub
Private Sub cmdTimeout_Click()
Dim lRow As Long
Dim ws As Worksheet
Dim Emp
Dim MatchRow As String
Dim SearchTable As Range
Set SearchTable = Sheets("JobTime").Range("A2:A" & Sheets("JobTime").Range("A" & Rows.Count).End(xlUp).Row)
Set ws = Worksheets("JobTime")
Application.ScreenUpdating = False
With Sheets("JobTime")
If EmpID = "" Then
MsgBox "Please Scan your ID", vbCritical, "Alert"
Else
If JobNo.Value = "" Then
MsgBox "Please Select an Job Number.", vbCritical, "Alert"
Else
MatchRow = Application.WorksheetFunction.Match(JobNo.Value, .Range(SearchTable.Address), 0) + 1
.Cells(MatchRow, 3).Value = Now
End If
'Clear userform
JobNo.Value = vbNullString
Me.EmpID.SetFocus
Application.ScreenUpdating = True
End If
End With
End Sub