i have taken an label 6 for display number of hours taken by an user
taken from the current login time to logout time
and there is break time 1:30 to 2:15 pm
how can i write an vba code
this is my login vba code
taken from the current login time to logout time
and there is break time 1:30 to 2:15 pm
how can i write an vba code
this is my login vba code
Code:
Private Sub cmdbt1_Click()Dim irow As Long
Dim ws As Worksheet
Dim info
info = IsWorkBookopen("\\bms\Service log request\login details\workstation.xlsx")
'we open the workbook if it is closed
If info = False Then
Workbooks.Open ("\\bms\Service log request\login details\workstation.xlsx")
End If
Set ws = Worksheets("Login Time")
'Find first empty row in database
irow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'Check for a Name number
If Trim(Me.TextBox1.Value) = "" Then
Me.lbl2.SetFocus
End If
'Copy the data to the database
ws.Cells(irow, 1).Value = Me.lbl2.Object
ws.Cells(irow, 3).Value = Me.lbl4.Object
ws.Cells(irow, 4).Value = Me.lbl6.Object
ws.Cells(irow, 2).Value = Me.Label2.Object
ws.Cells(irow, 5).Value = Me.TextBox3.Value
ws.Cells(irow, 6).Value = Me.TextBox1.Value
ws.Cells(irow, 7).Value = Me.TextBox2.Value
'Me.lbl2.Name = ""
'Me.lbl4.Name = ""
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox1.SetFocus
'Application.DisplayAlerts = False
Workbooks("workstation.xlsx").Save
Workbooks("workstation.xlsx").Close
Application.DisplayAlerts = True
MsgBox "welcome to bms"
End Sub
Last edited: