Manually log off user in vba ms-access (1 Viewer)

ilanray

Member
Local time
Today, 21:56
Joined
Jan 3, 2023
Messages
123
Hello
I have few users that login at the same time. from time to time I would like to upgrade my vb code or forms and for that I need that every one will log off.
but I don't want just close, I would like to send a pop up with countdown.
my soulution is
1. I have a users table. I added yes/no field called "shutdown".
2. created a form that countdown 10 sec and a bottun to close it if the users needs to work (the code check if the record on the users table is checked
3. i tried to call the form in the "on open" event
the form it self works and close the form after 10 sec. but if i checked the "shutdown" field in the middle of the workd it doesn't cdo anythinf

Can someone help me with that? or maybe even another soulution for that?

regards
 
I'm not quite clear on your question?

My guess is if the code is inside the form, you are closing the form before the code has a chance to complete.
 
Sounds like you users are all using the same FE and perhaps the app is not even split?

please clarify your actual setup
 
I split the database and the users can work simultaneous. and the problem is not with the close form
I will try to explain shortly again
I would like to mark the users in the users table so all the users will log off from the ms-access
 
and the users can work simultaneous
So each user is using the same FE file located in a shared location? Rather than each user having their own copy of the FE file on their local machine?
 
I did this by having a form that never closed, though it might be visually overlaid when another form opened. It was a "dispatcher" form and whatever form you requested to use would go on top of it. This form had a timer inside that checked a table for shutdown events. I would put a start time and stop time in the table, the start and end dates & times for the shutdown. When a user logged in, if the current time was between a start and end time, it would make the user log out immediately by forcing an Application.Quit, with a little pop-up warning form that was itself on a timer so IT would go away after 10 seconds. (A message box DOES NOT WORK for this, since it requires an OK click.) The harder trick was if the user was logged on before I loaded the times. Which forced me to plan ahead of time to put enough warning time in the start time. I.e. this method DID NOT do well with emergency shutdowns. It was a bit sluggish for emergencies.

The hidden form's timer checked about every 15 minutes, so I had to give myself a 30-minute lead time before the start. I only looked at shutdown entries where the end time was in the future, and the query also did an ORDER BY of the start times to get the closest start time first. Therefore, a DLOOKUP of that query always gave me the next start time. IF the next start time was in the future and less than 1 hour away, I would pop up that little warning form to say "Shutdown scheduled for xx:xx today, ending at yy:yy" and change the timer from 15 minutes to 5 minutes. That would repeat the pop-up more often. Then when the shutdown was within 5 minutes, I would change the timer to 1 minute. Essentially, I annoyed the hell out of the users to get off the DB. And when the timer saw that the start was in the past but the end was in the future, it did the same thing that the logging-in user would see - "This DB is shutdown, scheduled to return to service at yy:yy" - and do the Application.Quit

The trick was to go into each form and force it to close. My "OnClose" routine had to be coded to recognize the possibility that a "forced close" could occur, so this shutdown had a "global" flag that said "Forced Shutdown." On forcing the form to close, if the flag was set the close routine would force an UNDO on the form and allow the close of a (no longer dirty) form.

Then, to keep things from getting crazy, as soon as it appeared that everyone was out of the DB, I would RENAME the BE file or move it to a staging folder, so that when an insistent user tried to log in again, the BE wouldn't be there and the FE would die. I would put it back only when it was safe.

No, I don't have any code to give you because this work was done under contract. I don't own the code and could not legally copy it when I retired.

EDIT: For clarity, this worked on a split FE/BE where the down-time table was in the BE and the rest of it was in the FE.
 
Last edited:
We still haven't gotten a response regarding whether or not the users are sharing the same physical copy of the FE or have their own. To be specific, each user should have his own copy of the FE. The master copy resides on the server and you use a shortcut to run a batch file or another procedure that copies down new versions of the FE as needed. We can help with the set up if that is your problem.

Also, unless you have an emergency fix to distribute, replacing the FE during business hours is poor practice.

You might find this tool useful though.

 

Users who are viewing this thread

Back
Top Bottom