Can an Access db 'detect' when a user locks a PC? (1 Viewer)

Alc

Registered User.
Local time
Today, 07:57
Joined
Mar 23, 2007
Messages
2,343
In order to prevent the pain that is an unknown user being in a database when I need to make a fix/upgrade, I've built the following into the various databases we use:
1. If a db is idle for 15 minutes, it closes
2. If I want to 'kick' someone, I can do it by setting a field in a table to true

The problem I have, from time to time, is if someone uses Ctrl, Alt + Del and locks their PC/laptop before leaving the building. In such cases, neither of the previous changes will run and I have to wait until they come back into work the next day. Is it possible, somehow, to either:
1. Have Access detect that a computer is being locked and shut itself down
2. Somehow 'trap' the event on the computer itself and then force any open dbs to close?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:57
Joined
Oct 29, 2018
Messages
13,202
Hi. Interesting question. Are you saying if the user locks the computer, Access stops running? I didn't realize that.
 

Alc

Registered User.
Local time
Today, 07:57
Joined
Mar 23, 2007
Messages
2,343
Hi. Interesting question. Are you saying if the user locks the computer, Access stops running? I didn't realize that.
Thanks for the response.
No, sorry, Access itself is still running, but the event that's meant to fire based in the form's timer property doesn't fire.

One of the ways I shut down the db currently involve a hidden form checking some value in a linked table every three minutes. If the value is false, nothing happens. If the value is true, the db displays a warning to the user then shuts down. When I want to kick out a user, I go to the remote back end and set the flag to true.

If the user leaves his laptop open and goes on lunch, this process still works. If, however, he locks it and goes, the event won't fire until he comes back and unlocks it.
 

Alc

Registered User.
Local time
Today, 07:57
Joined
Mar 23, 2007
Messages
2,343

Cronk

Registered User.
Local time
Today, 23:57
Joined
Jul 4, 2013
Messages
2,435
I'll assume it is not in the FE that you are wanting to make changes because all users should be running their own copy of the FE on their own PC.


You could put code in the FE that runs on start up to modify table structure. Of course that won't work if a user has the BE open 24/7
 

Alc

Registered User.
Local time
Today, 07:57
Joined
Mar 23, 2007
Messages
2,343
You could put code in the FE that runs on start up to modify table structure. Of course that won't work if a user has the BE open 24/7
What do you mean by modifying table structure?
The back end wouldn't be open, just locked by opening the front.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:57
Joined
Oct 29, 2018
Messages
13,202
Thanks for the response.
No, sorry, Access itself is still running, but the event that's meant to fire based in the form's timer property doesn't fire.

One of the ways I shut down the db currently involve a hidden form checking some value in a linked table every three minutes. If the value is false, nothing happens. If the value is true, the db displays a warning to the user then shuts down. When I want to kick out a user, I go to the remote back end and set the flag to true.

If the user leaves his laptop open and goes on lunch, this process still works. If, however, he locks it and goes, the event won't fire until he comes back and unlocks it.
Okay, this intrigued me, so I created a quick test to see if I could find out what is happening. I created a form with a timer and opened it. I can see the timer is working. I then locked my computer and went away for a while. When I came back and unlocked the computer, I can see (from the crumb trail I left in the Immediate Window) that the timer never stopped running. So, I am not sure I understand why your "kickout" code is not working when the user locks the computer.
 

The_Doc_Man

Immoderate Moderator, Former MVP, Retired SysAdmin
Staff member
Local time
Today, 06:57
Joined
Feb 28, 2001
Messages
18,347
Good test, theDBGuy. I was intrigued by this when I saw it because, like you, I would have said that locking a computer doesn't stop code from running. (But I was at the eye doctor today so just now returned to my system when my vision cleared.)

Access runs in the background without assistance even when the computer is locked. Things that stop it are ANY type of input option like a message box (even with the OKOnly response option), an input box, or any action the triggers any OTHER event that would execute based on user input, but events cannot interrupt other events. Also, any form that runs in MODAL status will block all other code in that app. So if a timer-based event triggers a form shutdown and that triggers a confirmation but you aren't there, that event HANGS - and blocks all other code in that task.

If your timer tries to shut down a form but you have code to require some user action to undo something, and you need another event, you might be in a "deadly embrace." For instance, if you have code to disallow a user to save a record by just navigating (because you disallow closure of a dirty form without saving and disallow saving without hitting a SAVE button, as one example), this means you cannot close the form while the computer is locked unless the TIMER issues the UNDO followed by the CLOSE operation. I'm sure I could come up with other examples.

And remember, events cannot interrupt other events. They are handled linearly in order of being triggered unless there is an event sequence implied in an action. Therefore, if any event requires something and doesn't have it, you are deadlocked.
 

isladogs

CID VIP
Local time
Today, 12:57
Joined
Jan 14, 2017
Messages
14,018
Just to reinforce the previous two answers, I have an inactivity timer in two of my schools apps. After a set time, the app closes if no activity has occurred. Locking the workstation does not affect this process.

We added that feature for exactly the same reason as you. To ensure that nobody had their FE left open when the BE data was being updated from an external source or when running scripts to update the table structures in the BE. We could also reliably boot out everyone if the system needed to be closed for essential maintenance

Once we got the code working properly, the system was 100% effective.
 

Alc

Registered User.
Local time
Today, 07:57
Joined
Mar 23, 2007
Messages
2,343
Thanks all for the feedback.

This one clearly needs more investigation as, from everything that's said, a locked computer should not prevent the db from being shut. Something, however, is and I'll need to narrow down the cause.

Edit: Really puzzled now.
I just tested this on my own laptop and a colleague's laptop.
Opened the same database, set the flag to true in the relevant table, after three minutes, both databases shut down.
Reopened them, locked the laptops, after five minutes I unlocked both and my database has shut down while his was still running.
 
Last edited:

Minty

AWF VIP
Local time
Today, 12:57
Joined
Jul 26, 2013
Messages
7,516
Although possibly not related, if this is a laptop then sometimes depending on the set up, when locked, the network connections "go to sleep" so any external connections are dropped.

That might prevent an external lookup from working?
 

Alc

Registered User.
Local time
Today, 07:57
Joined
Mar 23, 2007
Messages
2,343
Although possibly not related, if this is a laptop then sometimes depending on the set up, when locked, the network connections "go to sleep" so any external connections are dropped.

That might prevent an external lookup from working?
Aha! That sounds possible.

In spite of all the laptops supposedly being the same, I do know some people have a much lower connection speeds. If there's a difference in one area, there may well be in another.
 

Minty

AWF VIP
Local time
Today, 12:57
Joined
Jul 26, 2013
Messages
7,516
I had a user complaining that his database kept crashing...
His used to "sleep" after 20 minutes of inactivity, and he lost all network connectivity. It just needed the power setting adjusted.

I guess you could check for the backend network connection and simply close down if it wasn't there, as they wouldn't be connected properly anyway without it?
 

The_Doc_Man

Immoderate Moderator, Former MVP, Retired SysAdmin
Staff member
Local time
Today, 06:57
Joined
Feb 28, 2001
Messages
18,347
Look into the "power-down" policy, which is where screen savers, sleep-mode, and network activity triggers are managed. However, I'm thinking that the local "sleep" functions, if they include "hibernate" as an option, would even stop a timer. Timers require code to be running in order to trigger, and if a task is put into an involuntary wait state, code might not be able to run. I agree with what Minty suggested but I believe it involves wider scope than just "network" connections.

Which leads to the question of whether at your site there is a set of policy downloads coming from the domain controller at machine restart and/or at user login? Because sleep policies can frequently be imposed by a domain admin for security reasons and they are not wrong to do this to you. But what you need to know is whether the domain's sleep policy timeout is SHORTER than your application shutdown policy. Because if so, it is possible that you never get to execute the app shutdown if the platform sleeps first.
 

Alc

Registered User.
Local time
Today, 07:57
Joined
Mar 23, 2007
Messages
2,343
I'm on vacation next week and may not get this resolved before I leave. I'll stay on it, however, and will post back what I find, in case anyone else finds it helpful.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:57
Joined
Aug 30, 2003
Messages
34,746
Geez, I didn't get an email notification and didn't realize this got resolved. I set up a test that was going to email out every minute, lock the PC and see if it still worked. Old news to you all that it worked fine.

I got sidetracked when i couldn't get the automated email to work on my new Win 10 computer, despite Outlook being set up and working fine. I had installed an MSDN version of Office, but it turns out there was an Outlook "app" installed as well, and automation was trying to use that by default, and of course it wasn't set up. My tipoff was seeing two of each Office app in the Start menu:

Access
Access
...
Excel
Excel
...
Outlook
Outlook

I uninstalled the app and all is well.
 

Users who are viewing this thread

Top Bottom