How Do I Kick the selected one out of a database. MSAccess 2016 (1 Viewer)

Local time
Tomorrow, 02:44
Joined
Nov 22, 2019
Messages
31
Hi Guys,

Can someone help me with code that need to go behind the Disconnect User and Send Message Button.

I tried to find but failed. Help is highly appreciated !
 

Attachments

  • Mdification.JPG
    Mdification.JPG
    79.3 KB · Views: 50
  • CheckCurrentUsers.zip
    78.7 KB · Views: 49

NauticalGent

Ignore List Poster Boy
Local time
Today, 17:14
Joined
Apr 27, 2015
Messages
6,286
Hi Guys,

Can someone help me with code that need to go behind the Disconnect User and Send Message Button.

I tried to find but failed. Help is highly appreciated !
akbarmahfuzalam, are you saying the code doesn't work or that you need help adapting it to your needs?
 
Local time
Tomorrow, 02:44
Joined
Nov 22, 2019
Messages
31
akbarmahfuzalam, are you saying the code doesn't work or that you need help adapting it to your needs?

Disconnect User when highlighted doesn't work and even Send Message Button too.

Can check my zip file NauticalGent
I need help in adapting it to my need.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 17:14
Joined
Apr 27, 2015
Messages
6,286
Do you get either of these errors when you open the app?
 

Attachments

  • Error1.PNG
    Error1.PNG
    6.7 KB · Views: 44
  • Error2.PNG
    Error2.PNG
    13.4 KB · Views: 49

isladogs

MVP / VIP
Local time
Today, 21:14
Joined
Jan 14, 2017
Messages
18,186
hi
The sample database can be found here Check logged in users
It was an updated version of a database originally written by David Crake and the two buttons were features he never got around to implementing.
In my example, the buttons were disabled.
See post #4 in that thread for further info together with a link to a SendMessage feature you could add yourself.
As I wrote in that thread, it isn't obvious to me why anyone would want to eject a specific user from a database or how to achieve that.
As I can't see a reason for doing it, I've not tried to implement the feature
 
Local time
Tomorrow, 02:44
Joined
Nov 22, 2019
Messages
31
hi
The sample database can be found here Check logged in users
It was an updated version of a database originally written by David Crake and the two buttons were features he never got around to implementing.
In my example, the buttons were disabled.
See post #4 in that thread for further info together with a link to a SendMessage feature you could add yourself.
As I wrote in that thread, it isn't obvious to me why anyone would want to eject a specific user from a database or how to achieve that.
As I can't see a reason for doing it, I've not tried to implement the feature

I agree with you isladogs but the requirement over here is different. When someone locked the workstation and went home accidentally . And in that case we want them forcefully logoff by selecting the user name.
Basically, I need them to log off forcefully because i need for maintenance purpose.
 

Minty

AWF VIP
Local time
Today, 21:14
Joined
Jul 26, 2013
Messages
10,355
I'm not sure it's possible to do unless you have remote access to their machine, in which case simply manually close the application down.

To explain - If you can't close the app down properly, there will be a lock file left behind that will need to be deleted or it will still leave the backend locked as it has some hooks into it.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 17:14
Joined
Apr 27, 2015
Messages
6,286
In addition to what IslaDogs and Minty have said, I would suggest a utility that detects inactivity and then logs out anyone who has been inactive over a specified period of time.
 
Local time
Tomorrow, 02:44
Joined
Nov 22, 2019
Messages
31
I know but that's where i stuck. Is there any possible way to to do so. Because every now and then someone forget to logoff the DB and then we need to struggle to find out the workstation where it is open. Approx 1000 workstation everyday.
 

isladogs

MVP / VIP
Local time
Today, 21:14
Joined
Jan 14, 2017
Messages
18,186
You don't need to detect which workstation has been left unattended.
Add code that measures the inactivity time-that is the time since the user entered/edited any data or moved to a new control/object.
After a specified time (I suggest 20 minutes), display a message warning the user the app will close in 30 seconds due to inactivity,
Within that time, if the user moves the mouse or does any other action, the clock is reset and the app stays open.

To remove all users from an app for maintenance , I use a different method to the example app.
I have a backend table tblKickout with a single Boolean field Kickout and one record.
A hidden form checks the value of that field every 30 seconds and if its set true by the program administrator, a 5 minute countdown procedure starts after which all users are ejected. That works whether or not the workstation is in sleep mode.

Hope that helps
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 16:14
Joined
Feb 28, 2001
Messages
27,001
When the user not only forgets to log off the database but then logs out of the terminal (or worse, forcefully shuts it down with the DB still open), that code won't help. The user won't see the message and the terminal, being in sleep mode or powered off, won't react to diddly squat anyway.

What is needed is for Windows on the back-end side to release the file lock on the .LDB file so that it can be deleted. That becomes painfully tricky. You might look at using the Command prompt and the OpenFiles command to list remote sessions, then kill that session that has the file open. The session will have a listener task and if you kill that listener, you can delete the .LDB file that had been kept open by it.

The ultimate method to handle this is user education. Grab the person who does this by the ears and shake them for a while. That might get their attention. (Just kidding, I'm not that violent.) But if it happens more than once or twice, get the boss involved to "have a talk" with this person who is making work for others by being lazy him/herself.
 

isladogs

MVP / VIP
Local time
Today, 21:14
Joined
Jan 14, 2017
Messages
18,186
Richard
It doesn't matter whether the user sees the message or not, the inactivity code and forced kickout code will still run.
In fact we tested on machines in sleep mode and the code still worked.
If the workstation is powered off when the app is still running, that can obviously cause issues but it needn't prevent essential maintenance being done. Sure it can be tricky deleting the lock file but if maintenance requires that to happen, it can be done
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 16:14
Joined
Feb 28, 2001
Messages
27,001
In the past I have had trouble with sleep mode, perhaps because for a while that was a bit "buggy." This wasn't on Win 10, might not have been Win 7 either. That's why I said what I did. And I didn't notice version numbers so don't know what configuration the OP is using.
 
Local time
Tomorrow, 02:44
Joined
Nov 22, 2019
Messages
31
In the past I have had trouble with sleep mode, perhaps because for a while that was a bit "buggy." This wasn't on Win 10, might not have been Win 7 either. That's why I said what I did. And I didn't notice version numbers so don't know what configuration the OP is using.
Win 10
 

isladogs

MVP / VIP
Local time
Today, 21:14
Joined
Jan 14, 2017
Messages
18,186

Users who are viewing this thread

Top Bottom