Go Back   Access World Forums > Microsoft Access Discussion > Theory and practice of database design

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 03-06-2019, 07:31 AM   #1
Alc
Newly Registered User
 
Join Date: Mar 2007
Location: Ontario
Posts: 2,308
Thanks: 48
Thanked 28 Times in 27 Posts
Alc will become famous soon enough Alc will become famous soon enough
Can an Access db 'detect' when a user locks a PC?

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?

Alc is offline   Reply With Quote
Old 03-06-2019, 08:09 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,912
Thanks: 57
Thanked 1,291 Times in 1,272 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Can an Access db 'detect' when a user locks a PC?

Hi. Interesting question. Are you saying if the user locks the computer, Access stops running? I didn't realize that.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 03-06-2019, 08:14 AM   #3
Alc
Newly Registered User
 
Join Date: Mar 2007
Location: Ontario
Posts: 2,308
Thanks: 48
Thanked 28 Times in 27 Posts
Alc will become famous soon enough Alc will become famous soon enough
Re: Can an Access db 'detect' when a user locks a PC?

Quote:
Originally Posted by theDBguy View Post
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 is offline   Reply With Quote
Old 03-06-2019, 09:56 AM   #4
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,334
Thanks: 40
Thanked 3,670 Times in 3,538 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Can an Access db 'detect' when a user locks a PC?

don't think you can detect it for the reasons stated in this link

https://www.codeproject.com/Question...r-Ctrl-Alt-Del

there is also this link, a bit old but principle still stands
https://stackoverflow.com/questions/...ckend-database
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 03-06-2019, 10:12 AM   #5
Alc
Newly Registered User
 
Join Date: Mar 2007
Location: Ontario
Posts: 2,308
Thanks: 48
Thanked 28 Times in 27 Posts
Alc will become famous soon enough Alc will become famous soon enough
Re: Can an Access db 'detect' when a user locks a PC?

Quote:
Originally Posted by CJ_London View Post
don't think you can detect it for the reasons stated in this link

https://www.codeproject.com/Question...r-Ctrl-Alt-Del

there is also this link, a bit old but principle still stands
https://stackoverflow.com/questions/...ckend-database
Thanks. I thought I was clutching at straws, but hoped someone might have found a workaround.
Alc is offline   Reply With Quote
Old 03-06-2019, 10:43 AM   #6
Cronk
Newly Registered User
 
Join Date: Jul 2013
Posts: 2,152
Thanks: 3
Thanked 470 Times in 463 Posts
Cronk will become famous soon enough Cronk will become famous soon enough
Re: Can an Access db 'detect' when a user locks a PC?

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
Cronk is offline   Reply With Quote
Old 03-06-2019, 11:43 AM   #7
Alc
Newly Registered User
 
Join Date: Mar 2007
Location: Ontario
Posts: 2,308
Thanks: 48
Thanked 28 Times in 27 Posts
Alc will become famous soon enough Alc will become famous soon enough
Re: Can an Access db 'detect' when a user locks a PC?

Quote:
Originally Posted by Cronk View Post
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.

Alc is offline   Reply With Quote
Old 03-06-2019, 12:15 PM   #8
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,912
Thanks: 57
Thanked 1,291 Times in 1,272 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Can an Access db 'detect' when a user locks a PC?

Quote:
Originally Posted by Alc View Post
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.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 03-06-2019, 12:56 PM   #9
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 14,575
Thanks: 92
Thanked 1,682 Times in 1,560 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: Can an Access db 'detect' when a user locks a PC?

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.
__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Old 03-06-2019, 01:28 PM   #10
isladogs
High Noon Moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 11,032
Thanks: 115
Thanked 3,017 Times in 2,744 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: Can an Access db 'detect' when a user locks a PC?

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.
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Colin (Mendip Data Systems)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


I know that you know that we both know nothing
isladogs is offline   Reply With Quote
Old 03-07-2019, 04:01 AM   #11
Alc
Newly Registered User
 
Join Date: Mar 2007
Location: Ontario
Posts: 2,308
Thanks: 48
Thanked 28 Times in 27 Posts
Alc will become famous soon enough Alc will become famous soon enough
Re: Can an Access db 'detect' when a user locks a PC?

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 by Alc; 03-07-2019 at 04:40 AM.
Alc is offline   Reply With Quote
Old 03-07-2019, 04:10 AM   #12
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 6,435
Thanks: 165
Thanked 1,738 Times in 1,707 Posts
Minty is a jewel in the rough Minty is a jewel in the rough Minty is a jewel in the rough
Re: Can an Access db 'detect' when a user locks a PC?

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?
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 03-07-2019, 05:55 AM   #13
Alc
Newly Registered User
 
Join Date: Mar 2007
Location: Ontario
Posts: 2,308
Thanks: 48
Thanked 28 Times in 27 Posts
Alc will become famous soon enough Alc will become famous soon enough
Re: Can an Access db 'detect' when a user locks a PC?

Quote:
Originally Posted by Minty View Post
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.
Alc is offline   Reply With Quote
Old 03-07-2019, 06:03 AM   #14
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 6,435
Thanks: 165
Thanked 1,738 Times in 1,707 Posts
Minty is a jewel in the rough Minty is a jewel in the rough Minty is a jewel in the rough
Re: Can an Access db 'detect' when a user locks a PC?

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?
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 03-07-2019, 06:08 AM   #15
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 14,575
Thanks: 92
Thanked 1,682 Times in 1,560 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: Can an Access db 'detect' when a user locks a PC?

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.

__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to detect if user has a touchscreen CJ_London Modules & VBA 6 03-06-2019 01:16 PM
Detect if user has not entered a criteria David Ball Modules & VBA 1 12-13-2014 09:41 AM
Detect if user saves database by typing ctl s? LGordon Modules & VBA 6 02-15-2013 01:40 PM
Detect if user is changing new or old record?? Wegets7 Modules & VBA 6 11-19-2004 03:59 AM
Can I detect the domain a user is on? stevievee Modules & VBA 1 03-20-2003 05:54 AM




All times are GMT -8. The time now is 09:19 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World