Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Run Code based on Time of Day
Richard Pitassy 
       
4 years ago
One of the Access users on my network goes home and leaves one or more Forms and/or Reports open.  Dozens of reminders have failed to change his behavior.  Since he is the boss, firing is not an option!

The "Close all Forms" code in the Code Vault will do the trick but I would like to know the best way to get that code to run automatically on his computer at 7:00 pm each day.  Any recommendations appreciated.

Thanks!
Kevin Robertson  @Reply  
          
4 years ago
You could put this in your main form (make sure the form can't be closed)
Set the Timer Interval to 1000

Private Sub Form_Timer()

    If Time() = #7:00:00 PM# Then
        ' code goes here
    End If
    
End Sub
Richard Pitassy OP  @Reply  
       
4 years ago
Thanks Kevin.  That will work.  I'm wondering if there is a way to get that code to run without being dependent on an open form?  There may be times with the user will want to close the Main Menu and exit Access during the day.  I suppose I could create another really small form that could be left open on the desktop but that feels like "cheating". :)
Alex Hedley  @Reply  
           
4 years ago
Richard Pitassy OP  @Reply  
       
4 years ago
Thanks
Allan McConnell  @Reply  
     
4 years ago
This is s timely question as I have the same issue and have just completed the Developer course dealing with the timer.
I mentioned in the course feedback that I would like to see something along these lines.
So thank you to Richard for asking and Kevin for answering.
Richard Pitassy OP  @Reply  
       
4 years ago
Thanks Allan.  I wound up creating a very small form that I located inconspuously (via Move/Size) that opens when my application opens and remains open as long as the application is running. Rather than just closing all open forms and leaving the Main Menu open, I decided to simply exit the application with the OnTimer event >= 7:00 pm.  Working well and solves the problem with my "forgetful" user.  If you'd like more details on my solution, just let me know.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

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/2/2026 12:21:31 AM. PLT: 0s