У одного из наших клиентов есть база данных MS Access, которая продолжает падать. Наш ИТ-отдел считает, что это происходит сбой, потому что: 1. Имеется только один логин, 2. Несколько человек используют один и тот же логин на разных машинах одновременно, 3. Те же люди покидают свой сеанс, когда они вошли в систему, когда не используют базу данных.
Я думаю, что эту проблему можно решить, переключившись на SQL Server, и у каждого будет свой логин. Во-первых, это поможет с контрольными журналами, а во-вторых, доступны параллелизм, тайм-ауты сеансов и другие параметры. Проблема с этим решением заключается в том, что клиенты не хотят переходить на SQL Server.
Итак, мой вопрос: есть ли в Access функция автоматического выхода из сеанса пользователя после X периода бездействия? Если да, может ли кто-нибудь предоставить документацию или ссылки о том, как включить эту функцию?
Всего 1 ответ
Создайте скрытую форму со следующим кодом в свойстве таймера включения (интервал таймера установлен на 1000)
Private Sub Form_Timer()
' IDLEMINUTES determines how much idle time to wait for before
' running the IdleTimeDetected subroutine.
Const IDLEMINUTES = 60
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
Sub IdleTimeDetected(ExpiredMinutes)
DoCmd.OpenForm "CountToExit"
End Sub
Создайте себе всплывающую форму со следующими настройками таймера.
' GRACEMINUTES determines how much idle time to count down once this form
' is opened before quitting the Access application.
Const GRACEMINUTES = 1
Static ElapsedTime As Integer
Dim TimeRemaining As Integer
Dim intMinutes As Integer
Dim intSeconds As Integer
Dim strTimePassed As String
Dim strOutput As String
On Error Resume Next
ElapsedTime = ElapsedTime + 1 ' Counts seconds instead of milliseconds.
ElapsedMinutes = ElapsedTime / 60
TimeRemaining = (GRACEMINUTES * 60) - ElapsedTime
' Has the countdown timer run out?
If TimeRemaining <= 0 Or Not IsNumeric(TimeRemaining) Then
' ...if so, then exit Access.
strOutput = "0:00"
Application.Quit acSaveNo
Else
intMinutes = Fix(TimeRemaining / 60)
intSeconds = TimeRemaining - (intMinutes * 60)
strOutput = Format(intMinutes, "0") & ":" & Format(intSeconds, "00")
End If
Me.Label3.Caption = "Auto shutdown timer: " & strOutput
End Sub
Запустите эту скрытую форму с вашим autoexec, и она будет проверять одну секунду, чтобы увидеть, изменил ли человек окна в Access. После 60 минут бездействия они получат окно с предупреждением о том, что у них есть 60 секунд, чтобы закрыть всплывающее окно, прежде чем доступ сохранится и завершится.