Automatically Log off idle users | Member | | Join Date: May 2007
Posts: 32
| | |
Hi,
We have a shared Access 2000 database shared among many users within the company I work for.
many times, users open up the shared database and forget to close it.
So I cant even make modifications to it after work hours since users are logged in.
Is there a way to log off users after a long period of inactivity?
Let me know, thanks
|  | Expert | | Join Date: May 2007 Location: Florida
Posts: 1,915
| | | re: Automatically Log off idle users Quote:
Originally Posted by NewtoAccess Hi,
We have a shared Access 2000 database shared among many users within the company I work for.
many times, users open up the shared database and forget to close it.
So I cant even make modifications to it after work hours since users are logged in.
Is there a way to log off users after a long period of inactivity?
Let me know, thanks Yes, but there is debate on the best way to accomplish it. Here is a link to Microsoft's way:
ACC: How to Detect User Idle Time or Inactivity http://support.microsoft.com/?id=128814 |  | Expert | | Join Date: Jan 2007 Location: California
Posts: 3,835
| | | re: Automatically Log off idle users Quote:
Originally Posted by NewtoAccess Hi,
We have a shared Access 2000 database shared among many users within the company I work for.
many times, users open up the shared database and forget to close it.
So I cant even make modifications to it after work hours since users are logged in.
Is there a way to log off users after a long period of inactivity?
Let me know, thanks Is there a form that will always be open? Use a global variable and public functions with the Timer, Mouse Move, and Key Press events on every form to track how long a person has been idle.
| | Member | | Join Date: May 2007
Posts: 32
| | | re: Automatically Log off idle users
I'll check out the website.
I do have a Mainform that links to other forms. Mainform always remains open even if other forms are being worked on.
I think I should put a timer on the MAINFORM. And then have countdown which alerts the user and gives them the option to reset timer or not.
How could I code this? And where on form should it be added? 'on current' ?
|  | Expert | | Join Date: Jan 2007 Location: California
Posts: 3,835
| | | re: Automatically Log off idle users Quote:
Originally Posted by NewtoAccess I'll check out the website.
I do have a Mainform that links to other forms. Mainform always remains open even if other forms are being worked on.
I think I should put a timer on the MAINFORM. And then have countdown which alerts the user and gives them the option to reset timer or not.
How could I code this? And where on form should it be added? 'on current' ? The link provides you with everything you need to implement one way of checking to see if someone's idle.Let us know if you have any touble.
| | Member | | Join Date: May 2007
Posts: 32
| | | re: Automatically Log off idle users
Thanks for the link. I added the forms as mentioned on the microsoft site, only problem is an option whether or not to continue working did not appear.
It just closed right away.
I want to give the user a warning before closing by checking yes/no. if nothing is selected then it should proceed with quiting app.
| | Member | | Join Date: May 2007
Posts: 32
| | | re: Automatically Log off idle users
This is what i have so far for sub routine action:
Sub IdleTimeDetected(ExpiredMinutes)
Dim Msg As String
strMsg = ""
strMsg = strMsg & "Application will CLOSE_"
strMsg = strMsg & "Click YES to continue working. Click NO to exit"
If MsgBox(strMsg, vbQuestion + vbYesNo, "No Activity detected") = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Else
Application.Quit A_SAVE
delayTimer = 10000
Application.Quit A_SAVE
End If
MsgBox Msg, 48
End Sub
|  | Expert | | Join Date: May 2007 Location: Florida
Posts: 1,915
| | | re: Automatically Log off idle users Quote:
Originally Posted by NewtoAccess This is what i have so far for sub routine action:
Sub IdleTimeDetected(ExpiredMinutes)
Dim Msg As String
strMsg = ""
strMsg = strMsg & "Application will CLOSE_"
strMsg = strMsg & "Click YES to continue working. Click NO to exit"
If MsgBox(strMsg, vbQuestion + vbYesNo, "No Activity detected") = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Else
Application.Quit A_SAVE
delayTimer = 10000
Application.Quit A_SAVE
End If
MsgBox Msg, 48
End Sub
Change this: -
Else
-
Application.Quit A_SAVE
-
delayTimer = 10000
-
Application.Quit A_SAVE
-
End If
To this: -
Else
-
Application.Quit acSaveYes
-
delayTimer = 10000
-
End If
-
You copied "Application.Quit A_SAVE" from Access 2.0 code. Access 2.0 is not Access 2000, rather it is the version that existed pre97.
| | Member | | Join Date: May 2007
Posts: 32
| | | re: Automatically Log off idle users
OK. I'll update the commands.
Still though, I want application to autoclose.
So if VBYesNo no button selected within 10 seconds, then I want app to proceed with closing anyway.
How can this be accomplished?
|  | Expert | | Join Date: May 2007 Location: Florida
Posts: 1,915
| | | re: Automatically Log off idle users Quote:
Originally Posted by NewtoAccess OK. I'll update the commands.
Still though, I want application to autoclose.
So if VBYesNo no button selected within 10 seconds, then I want app to proceed with closing anyway.
How can this be accomplished? You did not post all of your code, so you may need to replace object names in the code below with the appropriate object names from your code. -
Else
-
idleTime = 0 'reset counters
-
delayTimer = 10000
-
Do Until idleTime = 10000
-
'Hang loose
-
idleTime = idleTime + ElapsedTime
-
If idleTime = 10000 Then
-
Exit Do
-
End If
-
Loop
-
delayTimer = 0
-
Application.Quit acSaveYes
-
End If
-
|  | Expert | | Join Date: Jun 2007 Location: Israel
Posts: 2,584
| | | re: Automatically Log off idle users Quote:
Originally Posted by NewtoAccess OK. I'll update the commands.
Still though, I want application to autoclose.
So if VBYesNo no button selected within 10 seconds, then I want app to proceed with closing anyway.
How can this be accomplished? It cannot be accomplished in any way with msgbox.
While msgbox is active no events will be triggered in any form.
You should create your own form with warning message, Yes No buttons and timer.
Good Luck.
| | Familiar Sight | | Join Date: Apr 2007
Posts: 132
| | | re: Automatically Log off idle users Quote:
Originally Posted by puppydogbuddy Yes, but there is debate on the best way to accomplish it. Here is a link to Microsoft's way:
ACC: How to Detect User Idle Time or Inactivity http://support.microsoft.com/?id=128814
Not sure where to place this code: (From MS' support page)
4. Create the following procedure in the form module: (How to access the FORM MODULE?)
Sub IdleTimeDetected (ExpiredMinutes)
Dim Msg As String
Msg = "No user activity detected in the last "
Msg = Msg & ExpiredMinutes & " minute(s)!"
MsgBox Msg, 48
End Sub
|  | Expert | | Join Date: May 2007 Location: Florida
Posts: 1,915
| | | re: Automatically Log off idle users Quote:
Originally Posted by FishVal It cannot be accomplished in any way with msgbox.
While msgbox is active no events will be triggered in any form.
You should create your own form with warning message, Yes No buttons and timer.
Good Luck. FishVal,
If I understood correctly NewtoAccess wants the system administrator to have the last say before shutdown.. NewtoAccess requested (see below) a "no" response to trigger the application exit 10 seconds after it is clicked, which is what the above code does.
<<<<<<So if VBYesNo no button selected within 10 seconds, then I want app to proceed with closing anyway.>>>>>>
|  | Expert | | Join Date: May 2007 Location: Florida
Posts: 1,915
| | | re: Automatically Log off idle users
NewtoAccess,
the Form module simply means the code behind a form (e.g. your idleTimeDected form) as opposed to a standard module or macro. You need to decide how you want the code to work before proceeding.
|  | Expert | | Join Date: Jun 2007 Location: Israel
Posts: 2,584
| | | re: Automatically Log off idle users Quote:
Originally Posted by puppydogbuddy FishVal,
If I understood correctly NewtoAccess wants the system administrator to have the last say before shutdown.. NewtoAccess requested (see below) a "no" response to trigger the application exit 10 seconds after it is clicked, which is what the above code does.
<<<<<<So if VBYesNo no button selected within 10 seconds, then I want app to proceed with closing anyway.>>>>>> I'm curious whether you've tested the code.
I've checked that while MsgBox is active no Timer event will be triggered, no code will run asynchronously.
No such a problem with special form. In this case there are two opportunities:
1) to handle timer event from this warning form
2) to handle timer event from the IdleUser detecting form (somewhat more sophisticated)
Good luck.
|  | Expert | | Join Date: May 2007 Location: Florida
Posts: 1,915
| | | re: Automatically Log off idle users Quote:
Originally Posted by FishVal I'm curious whether you've tested the code.
I've checked that while MsgBox is active no Timer event will be triggered, no code will run asynchronously.
No such a problem with special form. In this case there are two opportunities:
1) to handle timer event from this warning form
2) to handle timer event from the IdleUser detecting form (somewhat more sophisticated)
Good luck. FishVal,
I don't follow you. My suggested code runs only if the response to the message to the MsgBox is "No", so the MsgBox is no longer active at that point.
|  | Expert | | Join Date: Jun 2007 Location: Israel
Posts: 2,584
| | | re: Automatically Log off idle users Quote:
Originally Posted by puppydogbuddy FishVal,
I don't follow you. My suggested code runs only if the response to the message to the MsgBox is "No", so the MsgBox is no longer active at that point. Sorry. Maybe I've not got a point. Lets straight it.
The logic is:
1. to detect idle user situation
2. to warn the user about db closing
2.1. User confirms quit -> quit
2.2. User denies quit -> restart idle timer
2.3. User doesn't respond within a definite time period -> quit
Am I right?
If so, MsgBox will be helpless in p. 2.3.
|  | Expert | | Join Date: May 2007 Location: Florida
Posts: 1,915
| | | re: Automatically Log off idle users Quote:
Originally Posted by FishVal Sorry. Maybe I've not got a point. Lets straight it.
The logic is:
1. to detect idle user situation
2. to warn the user about db closing
2.1. User confirms quit -> quit
2.2. User denies quit -> restart idle timer
2.3. User doesn't respond within a definite time period -> quit
Am I right?
If so, MsgBox will be helpless in p. 2.3. FishVal,
OK, In writing my code, I understood NewToAccess to mean he wanted the ability to click the "no" button on the message box before actually following through with the shutdown of the application. If that is the case my code works, If that is not the case, and he wants the shutdown to occur without having to click the "no" button, then your scenario would be correct.
|  | Expert | | Join Date: Jun 2007 Location: Israel
Posts: 2,584
| | | re: Automatically Log off idle users Quote:
Originally Posted by puppydogbuddy FishVal,
OK, In writing my code, I understood NewToAccess to mean he wanted the ability to click the "no" button on the message box before actually following through with the shutdown of the application. If that is the case my code works, If that is not the case, and he wants the shutdown to occur without having to click the "no" button, then your scenario would be correct. An old shit. Who will guard the guards.
Who will do it for himself, if he does it for everybody who doesn't do it himself.
:)
PS. Custom form provides additional functionality, for example displaying final countdown.
| | Familiar Sight | | Join Date: Apr 2007
Posts: 132
| | | re: Automatically Log off idle users Quote:
Originally Posted by puppydogbuddy NewtoAccess,
the Form module simply means the code behind a form (e.g. your idleTimeDected form) as opposed to a standard module or macro. You need to decide how you want the code to work before proceeding. pretty much as descibed on the MS support site. After a set amount of idle time, I would like the user to automatically logged-off
| | Familiar Sight | | Join Date: Apr 2007
Posts: 132
| | | re: Automatically Log off idle users Quote:
Originally Posted by Proaccesspro pretty much as descibed on the MS support site. After a set amount of idle time, I would like the user to automatically logged-off
I followed the directions on the MS support page. I put this code in the ON FOCUS EVENT
Private Sub Form_GotFocus()
Sub IdleTimeDetected(ExpiredMinutes)
Dim Msg As String
Msg = "No user activity detected in the last "
Msg = Msg & ExpiredMinutes & " minute(s)!"
MsgBox Msg, 48
End Sub
Not sure what to expect......How does the detectidletime form get focus?? Is there a macro I must write so that the form is constantly running in the background?
|  | Expert | | Join Date: May 2007 Location: Florida
Posts: 1,915
| | | re: Automatically Log off idle users Quote:
Originally Posted by Proaccesspro I followed the directions on the MS support page. I put this code in the ON FOCUS EVENT
Private Sub Form_GotFocus()
Sub IdleTimeDetected(ExpiredMinutes)
Dim Msg As String
Msg = "No user activity detected in the last "
Msg = Msg & ExpiredMinutes & " minute(s)!"
MsgBox Msg, 48
End Sub
Not sure what to expect......How does the detectidletime form get focus?? Is there a macro I must write so that the form is constantly running in the background? A picture is worth a thousand words. See the link below for a free download demo mdb with source code, entitled Detect & Logoff Idle Users. http://www.utterangel.com/pages/acce...nloads.aspx#18 | | Newbie | | Join Date: Dec 2007
Posts: 1
| | | re: Automatically Log off idle users
Hi,
I referred to the link of the ms support website and it works fine.
But is it possible to detect inactivity when one form is on top of another?
What I mean is I have a main form - formList and when I click on a command button within the formList, another form - formDetails will open up.
In other words, the formList must be open before I can open the formDetails.
I want to auto log off at formList and formDetails.
I've put the code in both forms. But while I'll keying in details in the formDetails - the formList will be inactive.
Basically what I'm looking for is - if the formDetails is opened, it will check inactivity on that form & log off from the application.
But if only the formList is opened, it will check inactivity on the formList.
|  | Similar Microsoft Access / VBA bytes | | | Forums
Visit our community forums for general discussions and latest on Bytes
/bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 229,136 network members.
|