Results 1 to 2 of 2
  1. #1
    annayanagi014 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    4

    How to record time logs after logging in and logging out

    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!
    Click image for larger version. 

Name:	lasd.jpg 
Views:	10 
Size:	44.1 KB 
ID:	19725
    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

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    password on your screen is misspelled

    its really not a difficult code issue - but the implementation that works depends on how you approach it....

    if the logout field is available (possibly not visible) in an open form - then in the close or quit event you can have: me.LogOutField = Now()

    if the logout field is sitting in a table with no form then you must know the key to that record and fire an UpdateQuery

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 12-22-2014, 11:07 AM
  2. Replies: 1
    Last Post: 11-01-2013, 04:05 PM
  3. Call Logging - Elapsed Measurement of time
    By mdjrmeyer in forum Forms
    Replies: 2
    Last Post: 06-21-2012, 03:37 PM
  4. Logging Changes
    By nichmeg in forum Programming
    Replies: 0
    Last Post: 12-06-2011, 02:47 PM
  5. Logging In
    By runtest in forum Programming
    Replies: 1
    Last Post: 02-21-2010, 11:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums