Is there a way to "time out the database" to shut it down?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to shut down a user after the database has been idle for a
period of time, (say an hour). Can you advise if there is a way to do this?
 
You will need a form that stays open as long as the database is open. It can
be hidden so the user doesn't see it. Set the form timer interval in the
Load event of the form and perhaps put the time the form opened in a text
box. Then in the Timer event of the form, check the current time against the
open time and if it has been open longer than the maximum time, DoCmd.Quit.
 
Nelson said:
I want to be able to shut down a user after the database has been
idle for a period of time, (say an hour). Can you advise if there is
a way to do this?

The following KnowledgeBase artice should get you started:

http://support.microsoft.com/default.aspx?scid=kb;en-us;210297
HOW TO: Detect User Idle Time or Inactivity in Access 2000

I couldn't find a corresponding article for Access 2002 or 2003, but I
don't see how they'd be any different.

Note that there could be a few other things going on in the database
than the specific items that article looks at, but you can extend the
concept to check for other activity.
 
I got this code from rolf.gerlicher(at)gmx.de
You call IdleTime() and get the duration in tick from the last time the
Keyboard was pressed or mouse was moved.

I think http://support.microsoft.com/default.aspx?scid=kb;en-us;210297, if
Ms Access is not active application and user is working with another
application, it will consider idle time. Depend on your need, you can use one
of these two idle detection methods.


Private Type PLASTINPUTINFO
cbSize As Long
dwTime As Long
End Type

Private m_typPLII As PLASTINPUTINFO

Private Declare Function GetTickCount Lib "kernel32" () As Long

Public Function IdleTime() As Long
On Error GoTo IdleTime_ErrHandler
m_typPLII.dwTime = 0
m_typPLII.cbSize = Len(m_typPLII)

GetLastInputInfo m_typPLII

IdleTime = GetTickCount() - m_typPLII.dwTime

IdleTime_NormalExit:
Exit Function

IdleTime_ErrHandler:
MsgBox Err.Description & ". Error number = " & Err.Number & ". Error is in
IdleTime."
Resume IdleTime_NormalExit
End Function


Regards
Tran Hong Quang
www.bicsoft.net
 
Back
Top