Force Shutdown 3
By Richard Rost
2 years ago
Schedule Forced Shutdown, Kick Users Out, Part 3 In this Microsoft Access tutorial, I'm going to teach you how to schedule a forced shutdown time for all users logged into your Microsoft Access database. In Part 3 we will create the shutdown form that warns the user of the impending doom and actually closes the database. Then we'll test it and make sure it works. Of course it works... I built it. LOL. MembersThere is no extended cut, but here is the database download: Silver Members and up get access to view Extended Cut videos, when available. Gold Members can download the files from class plus get access to the Code Vault. If you're not a member, Join Today!
PrerequisitesLinksRecommended CoursesRecommended Templates
Keywords TechHelp Access, forced shutdown Access database, schedule database closure, Access user logout, multi-user Access management, Access database maintenance, Access VBA automation, ACCDE files, Access timer event, database shutdown form, backend table backup, Access form properties, Access compactor template, database compacting, frontend updates automation, VBA code modification, status check logic Access
Intro
In this video, we continue the Microsoft Access Force Shutdown series with part three, where I show you how to create a custom shutdown form and automate the forced logout of users from your Access database. You'll learn how to set up timer-based events, design a warning form that prevents users from easily closing it, configure shutdown intervals, and test the process with multiple front-end copies. Tips for using ACCDE files and best practices for maintenance are included, so you can ensure that everyone exits cleanly when you need to perform database updates or backups. This is part 3.
Transcript
Today is part three of my series on forcing users out of the database. It's eight o'clock on a Friday night, you've stayed late to do some maintenance, to do some work, to push updates, to do some backups, and Joe down in accounting left again. Not thoroughly, and you forgot to log out the database. What are you going to do? Well, this is what you're going to do.
This is part three of my series, so if you haven't watched parts one and two yet, go watch those. You'll find links down below, and then come on back and I'll be waiting for you.
All right, so where we left off our front-end database, we've got it to be big. I don't really size it. Our front-end database timer event is now running. Let's go take a peek at it. Where are you? Timer event. Come here.
Okay, so we're checking the scheduled shutdown time. If that happens to be the case, we need to shut down. Look at what time the system started. If it didn't start after that shutdown time, we are going to open up our shutdown form and do a shutdown.
So let's build the shutdown form next. I'm going to copy my main menu form because the main menu has pretty much all the features that I want. It's already set up. It's not a form that holds records. The record selector is off, the navigation, all that stuff is off.
Let's go in here. We're going to just copy and paste, control C, control V. We'll call this the shutdown F, the shutdown form. This guy will open up when it's time to actually shut down. I am going to delete all of the objects from this form. We don't need any of that stuff.
I'm going to go into its source code, and I'm going to delete everything except the form close event. Leave that form close event, delete everything else. Make sure you're in the shutdown form.
By the way, I did this earlier when I was doing my run-through, and I accidentally was deleting this stuff out of the main menu form, and luckily I caught it and I could undo it. But just delete all of that stuff. All you want to leave in here is the form close event.
Same thing happens: if they are able to close this form, it's taking the database with it, but we don't want that happening for us while we're doing maintenance.
I am going to change the background color of the form to something bright and obnoxious, like red. Make it a little smaller. Let's add a label and drop it right there. This database, the contents will self-destruct in 30 seconds. A little shutdown. Shutdown in one minute or whatever interval you want.
Let's make it white and bold and bigger. That's good enough. Center it maybe. That's about what I did before. All right, something like this. If you want to put sounds in here, you can do whatever you want. Put animation, make it jump and spit out jelly beans, whatever you want it to do. It's up to you.
Now, if you're going to give them one minute, then set the form's timer interval to 60 seconds like that. But again, I'm going to give mine 10 seconds for the purposes of class to demonstrate it to you. All right. But you're going to want to set this as long as you want. You want to give them 10 minutes? Set it for 10 minutes. I don't care. Give them time to finish their work and shut down. That's fine.
You want to prevent them from closing this form, though. So in the form properties, I'm going to go to format and turn off the record selector, navigation buttons, scrollbars. I'm going to turn off the control box. That's the control box. Turn that off. You can click on that and go to close.
I'm also going to turn off the close button. But if they are able to, if they do know some shortcut trick to close it or whatever, then it's just going to take the whole database with them because of our code.
Now, what's this thing going to do? After 10 minutes or one minute or whatever it is, after this timer runs (for me, 10 seconds), what do we want to have it do? Literally just shut the database down.
If you want to give them another warning, you could say, hey, you got 15 seconds, and start beeping and all that stuff. That's up to you. I'm already giving them a warning. That's good enough for me. You've been warned. You will now exit.
That's it. And you could put that stuff in here if you want to, but I'm not going to put that in here for now because I want to see this actually working. I want to demonstrate it and have it actually working.
Save that. Always, why isn't it throwing a debug compile? Close this. Close this.
Now we're ready for prime time. We're pretty much done. You can add some more embellishments or some flavor to it if you want. That's up to you. But for me, I'm ready to test it.
So, what I'm going to do is save changes. Yeah, that's fine. I'm going to make copies of this to simulate other machines running. Obviously, you're going to make ACCDE files for them.
If you don't know what that means, it's basically a compiled version of your database. So they can't get into the design elements. They can't get into your VBA code or your form design or any of that stuff.
All of the other users on your database who don't need to modify the database design should be running an ACCDE file. It's the smartest thing you can possibly do. But again, for the purposes of class, I'm just going to simulate it by making multiple front ends right here.
So I'm just going to go copy, paste, and paste. We'll make two of them. We'll make this one front end two, and this one front end. So if you want, one will be me. I'm the developer; that's going to be my copy.
Open it up. Here's front end number one. I'm going to close this ribbon, and I'm going to resize the database to be about this big. Here's a trick for you: I've got the database at the right size. I'm going to close that. Now when I reopen it, it should reopen at that spot. There we go.
Now I'm going to move that out of the way. Come here. Slide you down here out of the way. Open up front end two. It should open up with the same dimensions. Come on, and pop right there. My system is running really slow today. We'll just hide that. I hate how that happened.
We'll open up numbers. I think someone mentioned in one of the Access developer forums that I read a lot of, the latest version of Access has been really, really sluggish. I'm not exactly sure why. They did something--those guys, those cheeky fellows.
I've got three copies of my database running here. This is simulating multiple users.
Now, me, I'm the admin. As you can see, these things are checking every 10 seconds. These are checking for an update, right, for commands. Every 10 seconds.
Now, let's pretend I'm the admin on this one here. I'm going to come in here. I'm going to go to my server table. Right now, it is 6:15 pm on January 29th. I'm going to hit the current date-time and put in here 6:16 pm. That's a date in the future, the time in the future.
Oh, I think I just passed it a second ago. If it doesn't catch it--oh, it caught it. There it goes. See, I didn't do anything. Those two systems caught it and they should shut themselves down in a few seconds here. I must have hit it just before the minute was up. See, perfect. There we go. They just shut down.
Let's do it again. Move this over here. And these up, front end two. And front end. There we go. Now notice they're not shutting down. They're checking, because the logic, what's the logic?
If this is in the past, then check to see when you started up. If you started up after that date-time, you don't need to shut down. You're good.
But if I come in here and issue another shutdown--okay, it's now at 6:17. I'm going to put 6:18 in here, which is again, a future date-time. Remember, you have to leave this thing. If this is dirty, it won't update. So I just updated.
Looks like it's 6:17 and 19 seconds. I've got a few minutes, there you go, in less than a minute. But for us, it's going to seem like forever. I'm going to pause recording.
I paused for about 20 seconds. It's now after 6:17 and 50 seconds, and it should catch that in just a second here. The 0.9. All right. 59 won't catch up, but the 0.9--oh, the other one caught it. There it goes because he's on 0.1. That guy should catch up right any second. Where are you? Come on. There it goes. OK. Nice little shutdown.
That's it. That's all she wrote. Go on. Close down. OK. Takes a second sometimes. It's not exact. Microsoft Access's timer is not exact. I've run into some problems before because if you do stuff on a timer where you count every second, sometimes it'll count evenly on seconds for like 5, 6 seconds, and then it'll pause for like 3 seconds because other system processes are going on. Then the 3 seconds will go by at once.
So you have to be careful if you're doing anything with timer-based actions, but this should work just fine for you with what we're doing here. Now you can do whatever updates and stuff you want.
That is how you set up your database to automatically boot users out.
I've got some other things that are related to this. I've got a good video on backing up your database. Watch this if you haven't yet already. I also have a backup template available. This is something that you put into your Access database so you'll program this to run after everybody else has been kicked out of the database.
You schedule it at 4 am or whatever time you want, and it will back up all of the tables that are associated with your database. Every backend table you've got in your database, it will back it up for you.
What I do is I back up my database files to my Google Drive. We don't want to run our database out of a Google Drive. That's a big no-no. Access does not run well out of a shared folder that's online.
But you can use Google Drive, Dropbox, OneDrive, any of those kinds of things. They're great for backup locations.
So your Access database can basically copy itself to your Google Drive, and then you've got an offsite copy of your database too, just in case the building burns down. You've got your database offline.
I also have another template called the Access Compactor. What this will do, I usually schedule this to run once a week, maybe once a month depending on how much your database is used. It will go through and compact all of your backend tables. I have mine run every Sunday, and I back up every night, and then I have the compactor run every Sunday.
I usually squeeze 2, 3, maybe 5 out of my database. Of course, remember, a small database is a fast database. If you get lots and lots of empty space in your database as well, the compactor will take care of that.
Finally, one of my more popular templates, I've got the Access Updater. If you're sick and tired of running around everyone's workstations and updating their front end, that's what this thing does.
You click one button, you push an update, and it will literally go to everyone else's workstations. Their database will pull down the updated copy, reboot, and restart the database for them automatically.
I'm using this myself; I built this for my own purposes. Even though I'm the only one in my office, I do have a server machine that sits over in the server rack and it does stuff. It sends out emails and it pulls down information from the website, monitors my mailing list, and all that stuff.
But even I don't want to get up and walk across the room and update a front end. So I click one button and it updates the front end. This can work on two machines or 200 machines; doesn't matter.
There's a link down there, check it out. All right, but that's going to do it.
That is how you force the shutdown of your database. Kick everybody out, tell them bye-bye, go get lunch. If there's anything else you want to see, if there's stuff you want to see me add to this, post a comment down below. If enough of you are interested, I'll be more than happy to make a part four.
For now, that's the end of the force shutdown series. Look down in the notes down below, because I won't update the video--you can't update a video on YouTube--but if I do post a part four eventually in the future, I'll put an update note in the description down below the video.
YouTube puts this stuff down here. It's blocked down here. It's easy to miss. A lot of people don't see this, but if you click that, there's all the stuff. I'll put notes down here. This is where I put the links and all that good stuff. Oh yeah, buy my coffee mug. Ha-ha-ha.
That's going to do it, folks. That's your TechHelp video for today. I hope you learned something. Live long and prosper, my friends. I'll see you next time.
If you enjoyed this video, please give me a thumbs up and post any comments you may have below. I do try to read and answer all of them as soon as I can.
Make sure you subscribe to my channel, which is completely free. Click the bell icon and select all to receive notifications when new videos are posted.
Want to learn more? Click the Show More link below the video to find additional resources and links. YouTube does a pretty good job of hiding it. It's right down there. See this part of the description here? The name, the video's up here. There's a little Show More down there, right down the bottom. It's kind of hard to find. But once you click on that, you'll see a list of other videos, additional information related to the current topic, free lessons, and lots more.
YouTube no longer sends out email notifications when new videos are posted like they used to do. But if you'd like to get an email every time I post a new video, click on the link to join my mailing list. You can pick how frequently to get emails from me, either as they happen, daily, weekly, or monthly.
If you'd like to become a paid member of my channel and receive all kinds of awesome perks, click on the Join button. You'll see a list of all the different membership levels that are available, each with its own special perks, including my extended cut videos, access to my code vault (lots of VBA source code in there), template downloads, and lots more. I'll talk more about these perks at the end of the video.
Even if you don't want to commit to becoming a paid member and you'd like to help support my work, please feel free to click on the tip jar link. Your patronage is greatly appreciated and will help keep these free videos coming. I've got some puppies to feed.
Don't worry, no matter what, these free TechHelp videos are going to keep coming. As long as you keep watching them, I'll keep making more, and they'll always be free.
If you really want to learn Access and you haven't tried my free Access Level 1 course, check it out now. It covers all the basics of Microsoft Access, including building forms, queries, reports, and more. It's over four hours long. You can find it on my website or on my YouTube channel. I'll put a link down below you can click on. And did I mention it's completely free? The whole thing--free, four hours, go watch it.
A lot of you have told me that you don't have time to sit through a four-hour course, so I do now have a quicker Microsoft Access for Beginners video that covers all the basics faster in about 30 minutes. No, I didn't just put the video on fast forward, but I'll put a link to this down below as well.
If you like Level 1, Level 2 is just a dollar. That's it, one dollar. That's another whole, like, 90-minute course. Level 2 is also free for paid members of any level, including supporters. So if you're a member, go watch Level 2--it's free.
Want to get your question answered in a video just like this one? Visit my TechHelp page and send me your question there. Members get priority, of course. While I do try to read and respond to all of the comments posted below in the comments section, I only have time to go through them briefly a couple of times a month, and sometimes I get thousands of them. So send me your question here on the TechHelp page and you'll have a better chance of getting an answer.
While you're on my website, be sure to stop by my Access forum. We've got lots of lively conversations about Microsoft Access and other topics. I have a fantastic group of moderators who help me answer questions. Shout out to Alex, Kevin, Scott, Adam, John, Dan, Juan, and everybody else who helps on the site. I appreciate everything you do. I couldn't do it without you.
Be sure to follow my blog, find me on Twitter, and of course on YouTube. I'm on Facebook too, but I don't like Facebook.
Now, let's talk more about those member perks if you do decide to join as a paid member. There are different levels: silver, gold, platinum, and diamond.
Silver members get access to all of my extended cut TechHelp videos, one free beginner class every month, and some other perks.
Gold members get all the previous perks plus access to download the sample databases that I build in my TechHelp videos, plus access to my code vault, where I keep tons of different functions that I use, the code that I build in most of the videos. You'll also get higher priority if you do submit any TechHelp questions. Answers are never guaranteed, but you do go higher in the list to meet the rhythm. If I like your question, you have a good chance of it being answered. You'll also get one free expert level class each month after you've finished the beginner series.
Platinum members get all the previous perks, plus even higher priority for TechHelp questions. You get access to all of my full beginner level courses for every subject, and I cover lots of different subjects like Word, Excel, VBA, ASP, lots of different stuff, not just Access. These are the full-length courses found on my website. You get all the beginner ones. In addition, once you finish the expert classes, you get one free developer class per month, so lots of training.
Finally, you can also become a diamond sponsor. You'll have your name or your company name listed on a sponsors page that will be shown on each video as long as you're a sponsor. You'll get a shout out in the video and a link to your website or product in the text below the video and on my website.
That's it. Once again, my name is Richard Rost. Thank you for watching this video brought to you by accesslearningzone.com. I hope you enjoyed it. I hope you learned something today.
Live long and prosper, my friends. I'll see you again soon.
Quiz
Q1. What is the purpose of the shutdown form described in the video? A. To display a warning before automatically closing the database for maintenance B. To let users customize database colors and themes C. To allow users to backup their own data D. To enable users to reset their passwords
Q2. When preparing the shutdown form, which event's code should you keep while deleting others from the copied menu form? A. Form load event B. Form close event C. Form resize event D. Form timer event
Q3. What key property changes does the instructor recommend for the shutdown form to prevent users from closing it easily? A. Enable the navigation buttons and scrollbars B. Turn off the control box and close button C. Set the form as a modal popup D. Change the record source to a table
Q4. What interval value should you set for the form's timer to determine how long the shutdown warning is shown? A. The length of time you want to give users before shutting down B. The time it takes for the database to compact C. The number of database users currently logged in D. The server time zone offset
Q5. What does creating an ACCDE file accomplish in the context of Access databases? A. It allows users to modify forms and code B. It compiles the database and protects design elements from user changes C. It enables web-based access to the database D. It increases the maximum size of the database
Q6. In the shutdown logic demonstrated, what happens when the scheduled shutdown time is in the past and a database instance started after that time? A. The user is locked out from all tables B. The database immediately shuts down C. The instance does not shut down since it started after the shutdown time D. The scheduled time is ignored
Q7. Why does the presenter caution against running an Access database directly from Google Drive or similar online folders? A. Online folders are too expensive B. There are security concerns with online folders C. Access databases may perform poorly or become corrupted in shared online folders D. Google Drive does not allow database files to be stored
Q8. What is the role of the Access Compactor template, as described in the video? A. To analyze and repair broken forms B. To compact and reduce the size of the backend database tables C. To provide summary reports for users D. To update the Access version automatically
Q9. What advantage does the Access Updater template provide? A. Allows batch deletion of old data tables B. Automatically updates the front-end database files on user machines C. Encrypts the entire database for security D. Scans for viruses within the database
Q10. Why does the instructor simulate multiple users by copying and opening multiple front-end database files? A. To test if the shutdown feature works safely with multiple concurrent users B. To increase the backend database size C. To backup more data D. To create duplicate records
Q11. What should you do before running a scheduled database backup according to best practices mentioned in the video? A. Notify the developer via email B. Make sure all users have been forced out of the database C. Increase the timer interval on all forms D. Recompile all the VBA code
Q12. What is a key disadvantage of relying solely on the Access timer event for precise timing tasks? A. It always runs at 2 minute intervals B. The timer is not always precise due to other system processes C. It cannot be programmed within forms D. It requires an internet connection
Q13. What feature does the Access Updater template automate for users? A. Pulling down the latest front-end version and restarting the user database B. Sending daily backup reports to users C. Creating new user accounts D. Scheduling regular compactions
Q14. According to the video, what is the most important reason for making regular offsite backups of your database? A. To have a web version available B. To prepare for future software upgrades C. To protect your data if the physical building is damaged D. To reduce the file size
Q15. What membership perk is unique to the Diamond Sponsor level as described in the video? A. Access to template downloads B. Shout out and listing on the website and videos C. Free beginner classes every month D. Access to the code vault
Answers: 1-A; 2-B; 3-B; 4-A; 5-B; 6-C; 7-C; 8-B; 9-B; 10-A; 11-B; 12-B; 13-A; 14-C; 15-B
DISCLAIMER: Quiz questions are AI generated. If you find any that are wrong, don't make sense, or aren't related to the video topic at hand, then please post a comment and let me know. Thanks.
Summary
Today's TechHelp tutorial from Access Learning Zone is the third part of my series on how to force users out of your Microsoft Access database when it is time for maintenance, updates, or backups. Picture this: it is late on a Friday night, you have stayed behind to handle some necessary work on the database, and of course, someone in accounting has forgotten to log out yet again. How do you proceed? That is exactly what this lesson is about.
Since this is part three, make sure you check out parts one and two if you have not already done so. The links are available on my website. Go through those first for the full context, and then come back here for the continuation.
Where we left off earlier, our front-end database now has a timer event functioning properly. The key idea is that we are monitoring a scheduled shutdown time. The process checks to see when the system started, and if that happened after the shutdown time, the database proceeds to open a special shutdown form and initiates the shutdown sequence.
The next step is to build this shutdown form. I like to keep things simple, so I start by copying the main menu form since it already has the features and formatting I like. I then remove everything from this copy except for the form close event in the code. This precaution is important: double-check that you are editing the shutdown form, not the main menu, because you only want to strip down this form for the shutdown process. The close event remains because, if a user manages to close this shutdown form, it takes the whole database down with it, which helps prevent users from bypassing the shutdown.
I change the background of the form to something bright and attention-grabbing like red, and size it down a bit. Then, I add a label with a big, clear warning indicating that the database will shut down soon, for example, "This database will self-destruct in 30 seconds" or "Shutdown in one minute." Adjust the timer interval on the form to match however much time you want to give the users—a minute, ten seconds for testing, or even ten minutes if you want them to have more notice. The main thing is to provide them with enough time to finish up and save their work before the system closes.
To prevent users from closing the shutdown form, I always turn off the record selector, navigation buttons, scrollbars, and most importantly, the control box which holds the close button. Disabling these reduces the chances of anyone circumventing the warning. Of course, some tech-savvy users might still find a way, but because of the shutdown code, if the form closes unexpectedly, the database shuts down anyway.
What happens next? After the set interval passes, the timer event simply shuts the database down. If you want to include a further warning—beeps, more messages, animation, whatever you prefer—you can add those, but I usually keep it straightforward: a single strong warning is usually enough.
Once the form is complete, I save all changes and ensure the code is clean. Now comes the testing phase. To simulate having multiple users running the front-end database, I create multiple copies of the front end. In a real-world scenario, you would distribute ACCDE files, which are compiled versions of your database that users cannot modify or peek into the code. Always have your users working from ACCDE files for security and stability.
I open up several copies of the front end to simulate different users. Each copy will continuously check for shutdown instructions based on the timer. As the administrator, I can go into the server table and set the shutdown time to a future value. When the system time passes that scheduled shutdown time, the timer event detects it, and the copies start the shutdown process as intended.
If the logic is set up correctly, active front ends continuously monitor the shutdown instructions—if they find that the scheduled shutdown time has passed but their session started after that point, they will not shut down. But each time I change the shutdown time in the server table to a future value, the connected front ends recognize it and trigger the shutdown process accordingly. This simulates a real-world scenario where you can remotely instruct the system to force everyone out.
Keep in mind that Access's timer event is not perfectly accurate—it may run slightly off, especially if the computer is doing other things, so there could be a delay of a second or two. That should not be an issue for this use case, but be aware of it if you rely on second-by-second accuracy for other applications.
This approach allows you to safely and efficiently get everyone out of the database, so you can proceed with maintenance, updates, or backups as needed.
Speaking of backups, I have a video dedicated to backing up your database, complete with a backup template that you can implement directly in Access. With this, you can set up your database to back up all backend tables at a scheduled time—say 4 am—and output the backups to locations like Google Drive, Dropbox, or OneDrive. Remember, do not run Access files directly out of these shared folders, but they make excellent destinations for backup copies, providing disaster recovery in case something happens to your building or local copy.
In addition, I have an Access Compactor template—this tool can be scheduled to compact your backend database periodically, cleaning up empty space and keeping the database running quickly. For most setups, a weekly or monthly compact should be sufficient, depending on how much activity your database sees.
Another useful resource is my Access Updater template. If updating front ends across multiple workstations is a chore, this tool automates the process. With the click of a button, you can push an updated front end to all users, who will then have their application refreshed and restarted automatically. I rely on this myself for keeping everything up to date, whether on a two-machine setup or across hundreds of users.
To sum up, by following this approach to forced shutdowns, you can ensure your maintenance and updates go smoothly. If you have thoughts, suggestions, or requests for further topics—say, a part four of this series—let me know in the comments on my website. I read all the feedback, and if there's enough interest, I'll be glad to continue with additional tutorials.
For more resources, including my free Access Level 1 course and a quicker Access for Beginners tutorial, links are available on my website. Level 1 covers all the basics over four hours, and if you want to move faster, the 30-minute beginners video is also available. Access Level 2 is just one dollar, or free for members at any level.
If you have questions you would like answered in a future video, use the TechHelp page on my website to send them in—members get priority, but I do my best to answer as many as I can. Also, check out the Access forum on my site for discussions and help from a great community of moderators and users.
There are several membership levels, each offering different perks such as extended cut videos, template downloads, access to my code vault with many useful VBA functions, higher question priority, and free courses on a variety of topics. Find details about those and more on the membership page of my website.
That wraps up this TechHelp tutorial on enforcing forced database shutdowns in Access. You can find a complete video walkthrough with step-by-step instructions for everything mentioned here on my website at the link below.
Live long and prosper, my friends.
Topic List
Reviewing and editing the database timer event
Copying and creating a dedicated shutdown form
Customizing the shutdown form's design and appearance
Setting the form's timer interval for shutdown
Configuring form properties to prevent manual closing
Programming the form to enforce forced shutdown
Testing forced shutdown by simulating multiple users
Using a server table to schedule database shutdowns
Synchronizing shutdown across multiple front ends
Explaining timer inaccuracy in Microsoft Access
Simulating user sessions for shutdown testing
Protecting your code by distributing ACCDE files
|