Results 1 to 11 of 11
  1. #1
    Join Date
    May 2006
    Posts
    178

    Unanswered: kick off if idle or remove

    Hi guys,

    Is it possible to create routine that will kick people off the database if they stay idle for too long?

    Also is there someway i can see who is accessing the database?

    Thanks

    Aboo

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    If it's an Access db, you can see who's in it with this post in the code bank.

    As far as kicking someone off, I've never tried this before but it looks promising.
    Me.Geek = True

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Yes and yes, but it takes a bit of doing.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    May 2006
    Posts
    178
    Thanks nckdryr & Trekker.

    The reason i ask is i want to set up a scheduled compact and repair (which is also my next question, how do i do it?)

    I take it i need everyone out of the database before this can be performed?

    Thanks

    Aboo

  5. #5
    Join Date
    May 2005
    Posts
    1,191
    I prefer to do a split front-end / back-end setup, then let the front-end auto C&R on close. I know there have been reported issues with C&R screwing up a database, so this way, worst case scenario I just have to reinstall the FE on the user's machine.
    Me.Geek = True

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    scheduled compact and repair should (in my books) be done as part of (say) an overnight task (ideally after you overnight backup is done so you have something to fall back to if the C&R goes belly up.

    you can use the windows scheduler to kick a process of at the required time (forget its location could be off the control panel). you could put the command to kick off the Access job as part of an existing batch job script

    you should look at Access command line switches (as ever Google is your matey)
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Feb 2004
    Posts
    214

    ...

    I once used a process to kick people out if they haven't updated a record in so long. Each record had a time and date stamp and I would run a process using the on timer function. every 30 seconds it would check to see if the system date was greater than 30 minutes from the last time stamp entry. If it was, it would shut down their database. Not sure if this will work for you. I also had a logout form attached to a table with only a yes/no. the form form would load as hidden. Again, usign the on timer function, it would check the value of the yes no every 30 seconds. If it ever was yes, it would run the docmd.exit.

    Hope this helps.
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  8. #8
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    One of the things that makes this hard is that you cannot detect idleness. You can only detect activity via event procedures... when a user navigates to a record or opens a screen or report. Every action would have to update a "LastActive" global date variable. The main menu form's Timer event can then examine this variable every 30 seconds or so and if it gets old, Quits.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  9. #9
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    If you use the routine here: http://www.dbforums.com/6274786-post19.html

    You only have to worry about compacting/repairing the "source" mdb which no one will ever be in (since this routine clones the source with the user's name and launches the mdb with the username attached. - so the user gets a fresh copy of the source every time they open it and no one is ever "using" the source mdb.)

    Plus, it has many other benefits (such as if you're creating temp tables), user's will always get a new fresh copy of the source mdb without all the temp data.

    I whole-heartdly prefer this over a timer event to close people out. Everyone can stay in their mdb as long as they want without affecting any other users or your ability to copy new code.
    Last edited by pkstormy; 06-05-09 at 01:02.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  10. #10
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Also,

    There's 2 other posts in the code bank with updated code that Nick posted. You can them here:
    http://www.dbforums.com/6283508-post38.html

    http://www.dbforums.com/6294427-post42.html
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  11. #11
    Join Date
    Aug 2003
    Location
    Bulgaria, Plovdiv
    Posts
    36
    Option Compare Database
    Option Explicit

    Private Const conMaxLockSeconds = 720

    Private Sub Form_Open(Cancel As Integer)

    ' Init timer interval (seconds)
    Me.TimerInterval = conMaxLockSeconds / 10 * 1000

    WrapUp:

    Exit_Form_Open:
    Exit Sub

    Form_Open_Err:
    MsgBox Err.Description
    Resume Exit_Form_Open
    End Sub


    Private Sub Form_Timer()
    Static slngTimerStart As Long
    Static sblnDirty As Boolean
    Call EditTimeLimit(Me, sblnDirty, slngTimerStart, conMaxLockSeconds, False)
    End Sub

    '---------
    Public Function EditTimeLimit(frmName As Form, _
    ByRef sblnDirty As Boolean, _
    ByRef slngTimerStart As Long, _
    Optional ByRef conMaxLockSeconds As Integer = 1000, _
    Optional ByRef bDisplayMode As Boolean = False)
    On Error GoTo EditTimeLimit_Err

    Dim intElapsed As Long

    If frmName.NewRecord Then
    Exit Function
    End If

    If frmName.Dirty Then
    ' Record has been modified since last save
    If bDisplayMode Then
    ' Init Edit Time
    SysCmd acSysCmdInitMeter, Msg("Edit time remaining") & ":", conMaxLockSeconds
    'intElapsed = 1
    End If
    ' Check if Timeout counter is running
    If sblnDirty Then
    ' Elapsed time may be over one minute, so
    ' grab both the minutes and seconds portion
    ' of the elapsed time
    intElapsed = (timeGetTime - slngTimerStart) \ 1000
    If intElapsed < conMaxLockSeconds Then
    ' Update Edit time remaining
    If bDisplayMode Then
    SysCmd acSysCmdUpdateMeter, intElapsed
    End If
    Else
    If bDisplayMode Then
    SysCmd (acSysCmdClearStatus)
    End If
    ' Timeout user and undo changes
    frmName.Undo
    ' Stop Timeout counter
    sblnDirty = False
    Call fPlayStuff(FilePathStripFileName(CurrentDb.Name) & "sounds\J0074828.WAV", 1)
    MsgBox Msg("You have exceeded the maximum edit time period of") & " " & _
    conMaxLockSeconds & " " & Msg("seconds") & "." & vbCrLf & vbCrLf & _
    Msg("Your changes have been discarded") & "!", _
    vbCritical + vbOKOnly, Msg("Record Timeout")
    End If
    Else
    ' Start timing the edits
    slngTimerStart = timeGetTime
    sblnDirty = True

    End If

    ' Record has not been modified since last save
    Else
    If sblnDirty Then
    ' User has saved changes, so stop timer
    sblnDirty = False
    If bDisplayMode Then
    SysCmd (acSysCmdClearStatus)
    End If
    End If

    End If

    Exit_EditTimeLimit:
    Exit Function

    EditTimeLimit_Err:
    Call LogMsgError(Err.Description, Err.Number, ModuleName$, "EditTimeLimit")
    Resume Exit_EditTimeLimit
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •