Results 1 to 3 of 3
  1. #1
    kron0120 is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2018
    Posts
    1

    Detect Idle Time from Database and kick inactive users

    Hello,

    I currently have a form with the below code and a macro to open the hidden form when the database is opened. Overall, it works perfectly for when users are using forms frequently and kicks them if they are inactive.

    However, there are some users who will leave a table open and inactive and this code does not kick the user from the database. I'm pretty new to coding in access so any help would be appreciated!




    Code:
    Private Sub Form_Timer()Static OldcontrolName As String
    Static OldFormName As String
    Static ExpiredTime
    
    
    Dim ActivecontrolName As String
    Dim ActiveFormName As String
    Dim ExpiredMinutes
    
    
    On Error Resume Next
    
    
    ActivecontrolName = Screen.ActiveControl.Name
    ActiveFormName = Screen.ActiveForm.Name
    Me.txtActiveForm = ActiveFormName
    
    
    If (OldcontrolName = "") Or (OldFormName = "") _
        Or (ActiveFormName <> OldFormName) _
        Or (ActivecontrolName <> OldcontrolName) Then
        OldcontrolName = ActivecontrolName
        OldFormName = ActiveFormName
        ExpiredTime = 0
    Else
        
        ExpiredTime = ExpiredTime + Me.TimerInterval
        
    End If
        ExpiredMinutes = (ExpiredTime / 1000)
        Me.txtIdleTime = ExpiredMinutes
        
    If ExpiredMinutes >= 20 Then
        ExpiredTime = 0
        Application.Quit acQuitSaveAll
        
    End If
    
    
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Most of us don't allow users directly into tables or queries. In this case, do they not have a form open at all? What is ActiveForm returning? You can test for that I would think.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    the forms can detect mouse/clicks/keystrokes motion, but a table/query cant.

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

Similar Threads

  1. Replies: 5
    Last Post: 02-15-2018, 03:11 AM
  2. Idle Time fix
    By rosscortb in forum Access
    Replies: 4
    Last Post: 11-07-2014, 12:58 PM
  3. Replies: 5
    Last Post: 09-04-2014, 01:52 PM
  4. Replies: 1
    Last Post: 06-04-2014, 08:23 AM
  5. Multi Users Access database gets Inactive
    By drunkenneo in forum Access
    Replies: 3
    Last Post: 11-14-2013, 03:12 AM

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