By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,737 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,737 IT Pros & Developers. It's quick & easy.

Automatically Log off idle users

P: 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
Jun 8 '07 #1
Share this Question
Share on Google+
22 Replies

puppydogbuddy
Expert 100+
P: 1,923
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
Jun 8 '07 #2

Rabbit
Expert Mod 10K+
P: 12,441
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.
Jun 8 '07 #3

P: 32
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' ?
Jun 8 '07 #4

Rabbit
Expert Mod 10K+
P: 12,441
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.
Jun 8 '07 #5

P: 32
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.
Jun 11 '07 #6

P: 32
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
Jun 11 '07 #7

puppydogbuddy
Expert 100+
P: 1,923
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:
Expand|Select|Wrap|Line Numbers
  1.            Else
  2.                Application.Quit A_SAVE
  3.         delayTimer = 10000
  4.         Application.Quit A_SAVE
  5.             End If
To this:
Expand|Select|Wrap|Line Numbers
  1.            Else
  2.       Application.Quit acSaveYes
  3.        delayTimer = 10000
  4.        End If
  5.  
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.
Jun 11 '07 #8

P: 32
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?
Jun 11 '07 #9

puppydogbuddy
Expert 100+
P: 1,923
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.
Expand|Select|Wrap|Line Numbers
  1. Else
  2.        idleTime = 0                          'reset counters 
  3.        delayTimer = 10000
  4.        Do Until idleTime = 10000
  5.              'Hang loose
  6.              idleTime = idleTime + ElapsedTime
  7.              If idleTime = 10000 Then
  8.                 Exit Do
  9.              End If
  10.        Loop
  11.        delayTimer = 0
  12.        Application.Quit acSaveYes
  13. End If       
  14.  
Jun 11 '07 #10

FishVal
Expert 2.5K+
P: 2,653
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.
Jun 11 '07 #11

100+
P: 132
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
Jun 11 '07 #12

puppydogbuddy
Expert 100+
P: 1,923
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.>>>>>>
Jun 11 '07 #13

puppydogbuddy
Expert 100+
P: 1,923
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.
Jun 11 '07 #14

FishVal
Expert 2.5K+
P: 2,653
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.
Jun 11 '07 #15

puppydogbuddy
Expert 100+
P: 1,923
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.
Jun 11 '07 #16

FishVal
Expert 2.5K+
P: 2,653
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.
Jun 11 '07 #17

puppydogbuddy
Expert 100+
P: 1,923
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.
Jun 12 '07 #18

FishVal
Expert 2.5K+
P: 2,653
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.
Jun 12 '07 #19

100+
P: 132
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
Jun 25 '07 #20

100+
P: 132
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?
Jun 25 '07 #21

puppydogbuddy
Expert 100+
P: 1,923
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
Jun 26 '07 #22

P: 1
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.
Dec 6 '07 #23

Post your reply

Sign in to post your reply or Sign up for a free account.