Results 1 to 2 of 2
  1. #1
    bobrulz is offline Novice
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    2

    Help storing Time with multiple users

    Alright, i've been driving myself mad for a day or two now trying to get this functionality working.


    So basically i'm building a database with multiple users to 'check in' and 'check out' multiple times per day (hoping 2 check in and 2 check out inc lunch). I have two tables linked, and originally I had this system partially working:

    Code:
    Private Sub btnCheckin_Click()
    Dim rs As Recordset
        
        Set rs = CurrentDb.OpenRecordset("tblEmployees", dbOpenSnapshot, dbReadOnly)
        
        rs.FindFirst "UserName='" & Me.txtUserName & "'"
     If rs.NoMatch = True Then
            Me.lblWrongUser.Visible = True
            Me.txtUserName.SetFocus
            Exit Sub
        End If
        Me.lblWrongUser.Visible = False
        
    Dim CountTime As Long
    CountTime = DCount("User", "qry_ClockIn_CheckSYSIn_1")
    
    
    Dim CountTime2 As Long
    CountTime2 = DCount("User", "qry_ClockIn_CheckSYSIn_2")
    
    
    If (CountTime > 0) Then
    MsgBox "You need to complete previous Clock Out", vbOKOnly
    
    
    ElseIf (CountTime2 > 0) Then
    MsgBox "You need to complete previous Clock Out", vbOKOnly
    
    
    ElseIf IsNull(Me.txtUserName) = True Then
    MsgBox "Scan Employee Barcode!", vbOKOnly
    Me.lblWrongUser.Visible = True
    
    
    
    
    Else
    
    
     
    
    
    Me.frmLogin_SUB.SetFocus
    DoCmd.GoToRecord , , acNewRec
    Me.frmLogin_SUB!User = Me.txtUserName
    Me.frmLogin_SUB!CheckIN = Now
    Me.frmLogin_SUB!Day = Date
    MsgBox "You have successfully clocked in at " & Now(), vbOKOnly
    RunCommand acCmdSaveRecord
    Me.frmLogin_SUB.Form.Refresh
    DoCmd.GoToRecord , , acLast
    
    
    
    
    Me.Refresh
    
    
    End If
      
    End Sub
    And for Checking out
    Code:
    Private Sub btnCheckOut_Click()
    Dim CountTime3 As Long
    CountTime3 = DCount("User", "qry_ClockIn_CheckSYSOUT")
    
    
    If IsNull(Me.txtUserName) = True Then
    MsgBox "Scan Employee Barcode!", vbOKOnly
    
    
    ElseIf (CountTime3 = 0) Then
    MsgBox "You have no open Clock In records. Please return to Clock In.", vbOKOnly
    
    
    Else
    
    
    If Me.Dirty Then Me.Dirty = False
    Me.Requery
    Me.txtCheckOUT = Now()
    MsgBox "You have successfully clocked out at " & Now(), vbOKOnly
    Forms!frmLogin.frmLogin_SUB.SetFocus
    DoCmd.GoToRecord , "User", acGoTo
    Forms!frmLogin.frmLogin_SUB.Requery
    Forms!frmLogin.frmLogin_SUB.Form.Refresh
    
    
    End If
    End Sub


    It partially works, however constantly creates new records, and I can't get it to work properly.
    The Query(s) consists of:
    qry_ClockIn_CheckSysIN_1
    Time ID
    Employee [Forms]![frmLogin]![txtUserName]
    TimeIN Is Not Null
    TimeOUT Is Null
    qry_ClockIn_CheckSysIN_2
    Time ID
    Employee [Forms]![frmLogin]![txtUserName]
    TimeIN
    TimeOUT Is Null

    qry_ClockIn_CheckSYSOUT
    Time ID
    Employee [Forms]![frmLogin]![txtUserName]
    TimeIN Is Not Null
    TimeOUT Is Null


    Hope that's enough information to help, and thanks for response in advance!
    even if there is something more simple or easier, as the code can be changed, it only needs to support multiple users that are checked by the rs function
    Cheers!

  2. #2
    bobrulz is offline Novice
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    2
    Got it all sorted!

    Cheers anyway!

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

Similar Threads

  1. Replies: 5
    Last Post: 08-20-2013, 09:37 AM
  2. Replies: 15
    Last Post: 03-21-2012, 08:44 PM
  3. Replies: 2
    Last Post: 03-01-2012, 04:14 AM
  4. Replies: 2
    Last Post: 11-14-2011, 09:16 AM
  5. Multiple users in database at same time
    By toshea in forum Security
    Replies: 4
    Last Post: 12-07-2009, 02:22 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