Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Are You There 2 < Are You There | Are You There 3 >
Are You There 2
By Richard Rost   Richard Rost on LinkedIn Email Richard Rost   3 days ago

Auto-Logout Users After Inactivity - Part 2


 S  M  L  XL  FS  |  Slo  Reg  Fast  2x  |  Bookmark Join Now

In this lesson, we continue building on the "Are You There?" video series by adding a message box timer to log users out of the database after a period of inactivity. I will show you how to import the necessary message box timer form and module, integrate them into your database, and set up the countdown and prompt to confirm user presence. We will walk through options for resetting the timer, handling user responses, and testing the process with a shortcut button. We will also discuss checking for activity on different forms and controls in the next lesson.

Members

There is no extended cut, but here is the file 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!

Prerequisites

Recommended Courses

Up Next

Learn More

FREE Access Beginner Level 1
FREE Access Quick Start in 30 Minutes
Access Level 2 for just $1

Free Templates

TechHelp Free Templates
Blank Template
Contact Management
Order Entry & Invoicing
More Access Templates

Resources

Diamond Sponsors - Information on our Sponsors
Mailing List - Get emails when new videos released
Consulting - Need help with your database
Tip Jar - Your tips are graciously accepted
Merch Store - Get your swag here!

Questions?

Please feel free to post your questions or comments below or post them in the Forums.

KeywordsAre You There? Automatically Log Users Out After Inactivity in Microsoft Access, Part 2

TechHelp Access, RU there, logging users out, inactivity log out, message box timer, timer event, user inactivity detection, on timer event, timer interval, default button value, active form checking, active control detection, status reset, cheat button, hex to RGB function

 

 

 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to Are You There 2
Get notifications when this page is updated
 
Intro In this lesson, we continue building on the "Are You There?" video series by adding a message box timer to log users out of the database after a period of inactivity. I will show you how to import the necessary message box timer form and module, integrate them into your database, and set up the countdown and prompt to confirm user presence. We will walk through options for resetting the timer, handling user responses, and testing the process with a shortcut button. We will also discuss checking for activity on different forms and controls in the next lesson.
Transcript Welcome to another TechHelp video brought to you by AccessLearningZone.com. I'm your instructor Richard Rost. This is part two of my RU there video series, logging users out if they go home for the night and just leave their database running.

If you haven't watched part one yet, go watch part one first and then come back.

We've got our little form sitting here just silently counting down an hour. You don't see anything happening unless we click that, and then we can see that updating. That's good.

Now we need to have the little pop-up if this thing does get down to an hour. For that, we are going to need the message box timer.

Since I'm a Gold Member on my own website, I can come down here and download it right from my website. That's another benefit of being a Gold Member. If not, you are going to have to watch these two videos, message box timer one and two, and build this yourself.

Like I said before in the last video, this is a prerequisite. We're going to use this. So I'm going to download this file.

Here it is. I'm going to open this up. Now, the stuff I need from here starts with message box timer. There it is. I need that form and that module so I can use this stuff in my new database. That's why I designed it like this, so it's nice and easy to copy and paste into a different database.

Let's go back to our RU there database. There we go. Now, I'll just copy both of these objects over to here. Pink, and there they go.

Now they should be both in here. There's message box timer F and the message box timer module. Now I can use my message box timer function in this database. So I can close this. Say goodbye. Thank you.

When this guy does count down and hit zero, its on timer event will fire. When that happens, first thing we're going to do is say

me.timer interval = 0

We're turning the timer off. I know it's set to something ridiculously high, but just in case, turn it off because at the end of this, we're going to turn it back on again.

Now, we're just going to say

if message box timer

Now there are a bunch of extra parameters in here in the free video because, in the extended cut, we added a bunch of stuff. But basically, we're going to start off by saying "Are you still there?" The title can be "Log out" or "Inactivity log out."

If you're following along from the free video, your message box timer just returns a true/false value. So, in your case, you would just close this and say "then." User selected Yes. So they're still there.

What do we want to do? We're going to status "activity detected, timer reset." Why? Because the status function itself is now going to reset the timer to an hour and turn the timer interval back on. So now we're all good.

Otherwise, user did not click Yes. Now we're going to shut down the database.

Now, you could put a Quit here, and that will actually close Access. I'm not going to do that just now, though. Instead of that, let's just pop up a message box for now for training purposes. "Database will close here," or "will close now," whatever.

If the timer hits zero, that means the hour has elapsed. Status hasn't been invoked in an hour. We're going to pop up the message box timer, "Are you still there?" It'll wait for 60 seconds.

If it comes back with a Yes, then OK, you're still here. We detected the status. We'll restart the whole thing. If not, if this comes back false, you get the message, you get the database closing, basically.

For you members, you have the extended cut video. We have a couple more options in here.

The first option is: what's the default value? We can do three buttons, so one, two, or three. I'm just going to make the default value one - that's fine.

We can set how many seconds. You can do 30 seconds, 60 seconds, 90 seconds, whatever you like. We'll just do one button. The button caption will say "Yes."

You can put up to three buttons, and then you can put a form back color if you want. The rest of that's fine.

We're going to say "if the message box timer" - let me make this another line here. Now, if this equals one, then OK.

Actually, the default value is what we give it if the user doesn't click that one, so we want to make that default value zero. Make the default value zero. That's the value that, if the button is not clicked, then it comes back as that.

This is good to go. Save it. Debug compile.

We've got, oh, hex to RGB. This is a member thing. Part of what we do in the extended cut is we set the color of the background form. So we need the hex to RGB. Members, go grab hex to RGB and bring it into the database. Or you can just rem that line out for now, and your colors just won't work.

Debug compile. OK, that's fine. I'm going to close these and save everybody, and then close the main menu and reopen it. Boop. And my form moved, of course. Now, this is just sitting here. We've got an hour to wait before it actually times out, so another thing I'm going to do is make a little cheat button on here.

I'm going to make a button where I can cheat the timer to run in like 10 seconds. This is my database while I'm testing it. So we're just going to drop a button on here. Cancel. We're just going to say "cheat 10 seconds." What we're going to do is set the timer interval to 10 seconds. Actually, let's do five seconds for the video.

When I click this button, it's going to reset that timer to five seconds, so I can make sure it's working. In here, this will be my cheat button.

You don't want to sit here for an hour and wait for it to run. Let's call this guy the cheat button. Right click build event. We're going to say

me.timer interval = 5000

and then a beep, so we know something happened.

Save it. Close it. Close it. Close our main menu. We'll put it back up again.

I'm going to also force a status in that main menu too. Let's do that real quick as well. Event right here. Right after we open this up, then we'll do a status.

Actually, now that I think about it, we don't even need this like this. We can just do this. Watch. The status function handles opening that form.

Sometimes I come up with these things as we're going along and I get good ideas. That's how database development is. You're like, oh, wait a minute. I can do that. Let's do this. That's why it's nice to learn new things, because now you can be like, oh, wait a minute. That database that I built last week, I could have done that in it. I do that all the time. I don't know how many times I've torn my own database apart because I learned something new.

We'll do a status "welcome." And we'll play that AOL guy, "Welcome. You've got mail." Because status will handle opening the form if it's not open already and loaded hidden.

One of the other things I do is I put a bunch of these in here whenever it's something that I have to remind myself to do later, because then it's like a quick to-do list inside my code. Now, all I have to do is a Ctrl+F to find and then just look for three of those in a row for the whole project, and it will take me to the next note that I made for myself.

Save it. Debug compile once in a while. Close it. Close it. Open it.

The initial status opened this guy, gave it some status in here. Now it's going to sit there and run for an hour unless we cheat and click the cheat button. I'm going to click the cheat button. I got five seconds not to do anything. Did it do - Jeopardy music plays. Oh, there it is. Are you still there?

Now, if I don't do anything, this guy is going to close and it should return to zero. I'm just going to hit Yes for now. It says "Activity detected, timer reset." Now we're back to the hour again.

Let's do this. I am going to also set that button so instead of 90 seconds, let's have it give us six seconds. I want to make sure that the timeout is working.

Let's try it again. Close this. Hello world opens that up.

Let's go to the five second timer. Jeopardy plays. Do do do do do, do do do do do.

There we go. This fails, it's going to log me out. Bing, database will close now. There we go. Database shuts down. That is working. It works great, and you can reset those to whatever values you want now.

There's one more thing that I'm going to do for the free video series to check for inactivity. As your users move it around, going between here, going between here, they might be on the same record for a while. Another thing we can check is if they are moving through different forms and different controls on the same form. Maybe it's a form you didn't think to put some kind of status messaging in. Maybe they're sitting on some other order form. But they're still doing stuff.

Another thing we can check, and I mentioned this at the beginning, this is one of the prerequisites for the first video, is we can also check the active form and active control. If that has changed, we can also assume the user is doing something.

We'll talk about that in tomorrow's lesson. Tune in tomorrow, same bat time, same bat channel. If you're a member, you can watch it right now because I'm still over recording tonight. I got a whole bunch of caffeine in me, so I'm going to be recording for another couple of hours.

We're going to do part three where I show you that. Then we're going to do an extended cut with a bunch of other cool stuff in it. But for everybody else, that's going to be your TechHelp video for today. Part two's over.

Hope you learned something. Live long and prosper, my friends. I'll see you tomorrow for part three.
Quiz Q1. What is the main purpose of the RU there video series described in the lesson?
A. To show users how to add new features to Access forms
B. To log users out of a database after a period of inactivity
C. To teach database normalization techniques
D. To demonstrate how to import data from Excel

Q2. What happens when the countdown timer in the form reaches zero?
A. The database automatically deletes user data
B. The timer resets without user notification
C. A message box timer pops up asking if the user is still there
D. The database backs up automatically

Q3. What function is used to display the inactivity prompt to the user?
A. MessageBoxNow
B. MsgBoxImmediate
C. Message Box Timer
D. AlertPrompt

Q4. What does the message box timer return in the free version described in the video?
A. An integer value indicating which button was pressed
B. A true/false value depending on user response
C. A string with the user's name
D. The time elapsed since the last activity

Q5. If the user responds "Yes" to the inactivity message box timer, what does the database do?
A. Logs the user out immediately
B. Resets the timer and keeps the user logged in
C. Deletes the current record
D. Exports the data to a file

Q6. In the extended cut, which of the following is NOT mentioned as a customizable option in the message box timer?
A. Default button value
B. Number of buttons
C. Form background color
D. Displaying an image in the message box

Q7. What is the purpose of the cheat button added during development?
A. To permanently disable the timer for admins
B. To quickly test the timer without waiting for an hour
C. To lock the database for all users
D. To enable printing of reports

Q8. What is the function of setting "me.timer interval = 0" when the timer event fires?
A. To restart the timer immediately
B. To submit the data automatically
C. To turn off the timer to avoid multiple firings
D. To refresh the entire database

Q9. Which method is suggested in the video to keep track of quick notes or to-dos in the code?
A. Creating a separate text file
B. Adding notes directly to the database properties
C. Using special markers (like three dashes) in the code and searching for them
D. Sending emails to oneself

Q10. According to the video, what else can be checked to determine activity other than timer and status messages?
A. Whether the database window is minimized
B. The user's internet connection status
C. Changes in the active form and active control
D. The number of users currently logged in

Answers: 1-B; 2-C; 3-C; 4-B; 5-B; 6-D; 7-B; 8-C; 9-C; 10-C

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 video from Access Learning Zone continues the discussion on how to automatically log out users from your Microsoft Access database if they leave the program open and are inactive, specifically focusing on part two of the "Are You There" series.

If you have not yet seen the first part of this series, I recommend watching that before proceeding, as it covers the basics and sets the foundation for what we're doing here.

So far, we have a form running silently that counts down from one hour. It's tracking inactivity, though you don't see any visible updates unless you deliberately check it. Now, the next step is to ensure that when the timer reaches an hour, a pop-up appears to prompt the user. For this, we'll be using the message box timer.

As a Gold Member on my own website, I have the convenience of downloading the message box timer database directly, a nice benefit for members. If you are not a member, you will need to follow the instructions in my two message box timer videos to build it yourself, since this functionality is a prerequisite for today's lesson.

Once the file is downloaded and opened, the key components needed are the message box timer form and module. These elements can be copied and pasted directly into your own database. I designed it to be easy to transfer, so integrating it with your projects should be straightforward.

After transferring those objects to our existing "Are You There" database, you will see both the form and the module in place, making the message box timer function available for use. With that set up, it's time to move on to handling what happens when the inactivity timer hits zero.

When the countdown completes, the form's timer event fires. The very first instruction is to turn the timer off by setting its interval to zero, as a precaution. Even if it was set to a large number, we want to ensure it does not fire again unexpectedly. Later, the timer will be re-enabled when appropriate.

Next is the message box timer prompt. In the free version, the function is set up simply: ask "Are you still there?" with a suitable title such as "Log out" or "Inactivity log out." The message box timer returns True if the user selects Yes. If that happens, you'll see a status update such as "Activity detected, timer reset," which both notifies the user and resets the inactivity timer for another hour by re-enabling it.

If the user does not respond positively, we will proceed to shut down the database. Although you can use the Quit command to close Access entirely, for demonstration purposes, I'm just displaying a message that says something like "Database will close now." You can modify this later to close Access if that's your preference.

So to summarize, when an hour of inactivity passes, the user gets a minute to respond. If they confirm their presence by clicking Yes, the timer resets. If not, the database closes.

If you are a member and following along with the extended cut, you will notice a few additional options. For example, you can specify the default button value, set up to three buttons, and customize the prompt duration. You can also set the button captions and even adjust the form's background color.

The default value indicates what response is recorded if the user doesn't click anything, such as zero if you want to treat a lack of response as inactivity. Make sure to adjust this setting appropriately.

One small issue might arise if you see a reference to a hex to RGB function, which is used for background color customization. Members can download this separately; otherwise, you can comment it out for now.

With everything in place and compiled without errors, you can test the implementation. To avoid waiting an hour during testing, I recommend adding a "cheat" button on your form that shortens the timer to just a few seconds. This way, by clicking the button, you can quickly verify that the pop-up and timer reset logic works correctly. The button sets the timer interval to five seconds, for example, and you can also include an audio cue using a beep to confirm the action occurred.

Additionally, to ensure the main menu starts the process correctly, call the status function upon opening it. This guarantees the hidden timer form is loaded and in place.

Database development often leads to improvements or shortcuts as you think of better ways to accomplish a task. For instance, once you identify that a function like status can simplify form management, you might adapt and update your approach, not just in this project but in others moving forward.

I also like to use markers inside my code as reminders of items to revisit later. It serves as a handy to-do list within my project, and I can easily search for these markers when working on maintenance or upgrades.

In testing mode, after clicking the cheat button and allowing the timer to count down, you'll see the message box pop up, prompting the user to indicate if they are still using the database. Responding Yes resets the timer; ignoring it leads to the database closing after the specified time.

If you want to experiment further, adjust the prompt time to a shorter duration to confirm that timeout behavior triggers as expected. When the allotted response time passes without a user action, the database closes just as intended.

Before wrapping up this portion of the series, there's one more technique to make inactivity detection more robust: monitoring movement between different forms and controls. Users might still be active even if they aren't switching records, especially if they are navigating through different screens or fields. By checking if the active form or control has changed, you can catch more subtle instances of user activity. This will be covered in the next lesson.

Join me next time for part three, where we'll address tracking changes in the active form and control as another way to monitor user activity. Members can access the lesson early, and I will also be putting together an extended cut covering even more advanced features.

For everyone else, that completes today's TechHelp lesson. As always, you can find a complete video tutorial with step-by-step instructions covering everything discussed here on my website at the link below.

Live long and prosper, my friends.
Topic List Importing the Message Box Timer form and module into a database

Implementing a countdown timer for user inactivity

Pop-up prompt when inactivity timer reaches zero

Using the Message Box Timer to confirm user presence

Resetting the inactivity timer upon user response

Handling user inactivity by closing the database

Adding a test button to simulate inactivity timeout

Setting timer intervals programmatically for testing

Integrating status updates to reset the timer

Using status function to manage form visibility and initialization

Debugging and compiling code after changes

Automating status checks on form load

Testing inactivity scenarios and timer resets
Article In this tutorial, I will show you how to implement an inactivity log out system in Microsoft Access. The goal is to automatically prompt users if they have left the database running for too long without activity, and log them out if they do not respond.

Suppose you have a database that users might leave open when they go home for the night. You want the system to recognize periods of inactivity, prompt the user with a message box, and, if there is no response, close the database.

To build this, we are going to use a form that silently counts down a set period (such as one hour). The form is hidden from users during normal operation, and ticks down in the background. When the countdown reaches zero, you want a popup to ask the user if they are still there. To do this, we will use a message box timer utility that gives the user a chance to respond within a specific time.

First, you need to bring the message box timer function into your database. If you have the message box timer form and its supporting module already created (from prior tutorials), you just copy both into your database. With the form and module imported, you now have the ability to pop up timed message boxes in your database.

With the setup ready, go to your timer form's code. The form uses the Timer event to keep track of inactivity. When the countdown reaches zero, the Timer event fires. At this point, you should turn off the timer by setting

me.timerinterval = 0

This prevents the timer from running while you await the user's response.

Next, use the message box timer function. The basic usage is to display a message box that will wait a certain number of seconds for a response. For example:

if MessageBoxTimer("Are you still there?", "Inactivity Log Out") then
Status "Activity detected, timer reset."
' This will reset the countdown and re-enable the timer
else
MsgBox "Database will close now."
' Or you could use Application.Quit to actually close Access
end if

The MessageBoxTimer function (available from the utility you imported) pops up a dialog asking if the user is still present. If the user clicks "Yes" within the time window, the function returns True, and you reset the timer as with the Status function. If the user does not respond or clicks anything else, you close the database or at least notify the user that it is about to be closed.

You can customize the message box timer with several parameters, such as the timeout duration, button captions, and default values. For example, you might use a 30 or 60 second timer, and set the default value to 0, which will be returned if the dialog times out without user input.

In the extended version of the code, you could write something like this:

Dim result as Integer
result = MessageBoxTimer("Are you still there?", "Inactivity Log Out", 0, 60, 1, "Yes")
if result = 1 then
Status "Activity detected, timer reset."
else
MsgBox "Database will close now."
end if

Remember to save and debug your code. If you get a compile error related to functions like HexToRGB (which are used for extended functionality like setting form color), you can comment those lines out if you are not using color customization.

To make testing easier, you might want to add a "cheat" button to your form that manually sets the timer interval to a few seconds. This allows you to quickly test the inactivity prompt without waiting a full hour. For this, add a button and in its click event, use

me.timerinterval = 5000
beep

This sets the countdown to 5 seconds for rapid testing, and the beep provides audio feedback.

Another tip is to include quick "to do" notes directly in your code using a distinctive marker like three consecutive characters. You can then use your editor's search function to jump to those as you continue developing your database.

When you run the form, the main menu opens and the hidden form starts counting down. If you click the cheat button, the countdown accelerates, and soon the timed message box pops up asking if you are still there. If you press "Yes," the system acknowledges activity and resets the timer as expected. If you ignore the prompt, the database notifies you that it will close, then proceeds to shut down.

In real-life use, the system will quietly monitor user activity for the duration you specify. If there is no detected activity, it asks the user to confirm they are present. If there is no response in the allotted time, it logs the user out to prevent leaving sensitive data exposed.

This tutorial covers the core of inactivity monitoring in Access using a timer form and a timed message box utility. For further enhancements, you might want to detect additional forms of user activity, such as moving between different forms or changing controls. This helps ensure that any user interaction resets the inactivity timer, even if the user is not performing the specific actions you originally anticipated. The next step would be to add such detection to your system to make it even more robust.
 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/22/2026 4:30:21 AM. PLT: 1s
Keywords: TechHelp Access, RU there, logging users out, inactivity log out, message box timer, timer event, user inactivity detection, on timer event, timer interval, default button value, active form checking, active control detection, status reset, cheat button,   PermaLink  Are You There? Automatically Log Users Out After Inactivity in Microsoft Access, Part 2