Results 1 to 6 of 6
  1. #1
    Dallash is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2018
    Posts
    3

    Auto disconnect idle users - I need to get a text box to appear before users get disconnected

    Hiya Guys.

    In my AccDB2013 i have created an auto idle disconnect function.

    It uses the following code in a hidden form opened by AutoExec macro.

    Private Sub Form_Timer()
    ' IDLEMINUTES determines how much idle time to wait for before
    ' running the IdleTimeDetected subroutine.
    ' **************************************************
    ' Set Idle Minutes in the next line
    ' It was originally set to 2 minutes
    ' *************************************************
    Const IDLEMINUTES = 15
    Static PrevControlName As String
    Static PrevFormName As String
    Static ExpiredTime
    Dim ActiveFormName As String
    Dim ActiveControlName As String
    Dim ExpiredMinutes
    On Error Resume Next
    ' Get the active form and control name.
    ActiveFormName = Screen.ActiveForm.Name
    If Err Then
    ActiveFormName = "No Active Form"
    Err = 0
    End If
    ActiveControlName = Screen.ActiveControl.Name
    If Err Then
    ActiveControlName = "No Active Control"
    Err = 0
    End If
    ' Record the current active names and reset ExpiredTime if:
    ' 1. They have not been recorded yet (code is running


    ' for the first time).
    ' 2. The previous names are different than the current ones
    ' (the user has done something different during the timer
    ' interval).
    If (PrevControlName = "") Or (PrevFormName = "") _
    Or (ActiveFormName <> PrevFormName) _
    Or (ActiveControlName <> PrevControlName) Then
    PrevControlName = ActiveControlName
    PrevFormName = ActiveFormName
    ExpiredTime = 0
    Else
    ' ...otherwise the user was idle during the time interval, so
    ' increment the total expired time.
    ExpiredTime = ExpiredTime + Me.TimerInterval
    End If
    ' Does the total expired time exceed the IDLEMINUTES?
    ExpiredMinutes = (ExpiredTime / 1000) / 60
    If ExpiredMinutes >= IDLEMINUTES Then
    ' ...if so, then reset the expired time to zero...
    ExpiredTime = 0
    ' ...and call the IdleTimeDetected subroutine.
    IdleTimeDetected ExpiredMinutes
    End If
    End Sub

    'Create the following procedure in the form module:
    Sub IdleTimeDetected(ExpiredMinutes)
    Application.Quit acSaveYes
    End Sub
    I want the database to close Down after 15 minutes time of inactivity, this it does. However i wish for it to open a window/box with the text "You have been idle for X minutes. The database will automatically shut Down in Y minutes."

    I have searched the web but not found anything i have been able to make Work. I sincerely hope someone will be able to point me in the right direction, as I am a newb.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    your timer works good IF the user only uses that form. What if they are in another form working, and form1 timer says nothing is happening even tho they ARE working in form2?

    tho, for your question, you would display a normally hidden label :You have been idle for X minutes.
    lblWarning.visible =giTime >
    IDLEMINUTES

  3. #3
    Dallash is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2018
    Posts
    3
    Good spotted, ranman256! And big thanks with assisting with the textbox. Any idea how to fix this tremendously big problem with not registrering Work in other forms etc?

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I would change the process - when the idle time needs to be shown to the user, make this form un-hidden, make it a pop-up form, and put the message and time on this form without the close/minimize button available to them. Then have a button they can click, which puts the form back to hidden mode and resets the timer.

  5. #5
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    my thought was to have a global variable, giTime
    whatever the current form is, any work would keep setting giTime = 0

    all forms would need to turn off the timer, timerinteval = 0
    when FORM_LOSTFOCUS

    when form_GOTFOCUS , turn the timer back on
    timerinteval = 1000 (1 second)

    all keyDown events would reset
    giTime = 0

    I havent tried this method in a long time, but give it a try.

  6. #6
    Dallash is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2018
    Posts
    3
    I must admit i am not all too well known in general VBA/SQL terms and structure.

    How do you think i would need to alter my code in order to implement one of either two options you suggest? :-) Sorry 4being n000b.

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

Similar Threads

  1. Replies: 32
    Last Post: 06-03-2015, 02:13 AM
  2. Code to disconnect users while update is running
    By Glenn_Suggs in forum Programming
    Replies: 2
    Last Post: 04-15-2014, 06:39 AM
  3. Auto fill Txtbox with logged in Users Name
    By pfales in forum Access
    Replies: 3
    Last Post: 04-30-2013, 01:22 PM
  4. Disabling Text Box for Certain Users
    By sky in forum Forms
    Replies: 1
    Last Post: 12-31-2009, 09:06 PM
  5. disconnected Remote Users?
    By Zermoth in forum Programming
    Replies: 0
    Last Post: 12-11-2008, 04:52 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