Our company needs to track the time and date per username when the employees log-in and logout in our database. i have a log-in form build with vba and i want to get the time and date also the username when the employee clicked log-in and log-out. I want to display it in another form named time tracker with 4 textbox namely Username, date, log-in time and log-out time. Can i have the code for that? thanks!
This is the code for my log in form:
Private Sub cmdLogin_Click()
If IsNull(Me.cbouser) Or Me.cbouser = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cbouser.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.password) Or Me.password = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.password.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this matches value chosen in combo box
Me.cbouser.SetFocus
If cbouser = "CMD" And password = "cmd123" Then
MsgBox "WELCOME!", vbOKOnly, "WELCOME"
DoCmd.OpenForm "cmd"
DoCmd.GoToRecord , , acNewRec
ElseIf cbouser = "MSGCNTR" And password = "msgcntr123" Then
MsgBox "WELCOME!", vbOKOnly, "WELCOME"
DoCmd.OpenForm "Msgcntr"
DoCmd.GoToRecord , , acNewRec
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.password.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub