Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Forums > Access
Back to Access Forum    Comments List
Close Report Using Timer Event Upload Images   Link   Email  
A Glenn Yesner 
I have vba that closes the database if the user is inactive for a period of time. This runs on a form timer in a navigation form that loads when the database is opened. Works great. However, if the user opens a report in print preview and leaves it open that freezes the timer and will allow the database to stay open until the report is closed. I've set the TimerInterval in the report to 1000  and put this code in the report's timer section;

Private Sub Report_Timer()
Dim Timecount As Long
Timecount = Timecount + Me.TimerInterval
If Timecount >= 5 Then
DoCmd.Close acReport, Me.Name
End If
End Sub

The 5 is just for testing, would actually set it for 5 minutes. No luck.

The button that called up the report initially used acPreview but after some research I changed it to acViewPreview as below;

DoCmd.OpenReport stDocName, acViewPreview, , "[ReportNumber]='" & Forms!frmModifyReport!ReportNumber & "'"

Still no luck, still stuck. Would appreciate some help.
Thank you, Ed
Richard Rost 
Interesting. I've honestly never used a timer event in a REPORT before. I'll play with it when I get some free time.
Kevin Robertson 
I just did some testing.

1 - You will need to move your Dim statement to the declaration section at the top of the code window otherwise the variable doesn't increment.

2 - You are incrementing your variable by the value in TimerInterval (1000) so you need to check for 5000, not 5.

I tested this in my Main Menu form opened up a Report and when the timer variable reached the specified value the database shutdown as expected.
Richard Rost 
Yeah, like I said, I haven't played with it in a report, but I don't see a report being open STOPPING the timer event on the Main Menu from functioning. It should still shut the database down. Should. :)
A Glenn Yesner 
It's probably the way it is written, the VBA tracks activity between forms and from control to control within a form. When the report is opened it takes the focus off the form and  the timer pauses (I have a text box that shows the countdown). Thank you Kevin, I'll try your way tomorrow.
A Glenn Yesner 
Kevin, I was finally able try your suggestion, it only works if I open the report in acViewReport mode but then I get an error message saying "No Current Record" but it opens and prints the report on the record I want. I'm attaching pictures of what I have done and it works, except for the error message. I've tried to set warnings to false but the error message still comes. The first picture is for the command button that opens the report, the second picture is for the timer sub and the third picture is the error message.
A Glenn Yesner 

A Glenn Yesner 

A Glenn Yesner 

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

 
 
 

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 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/28/2024 10:36:35 AM. PLT: 0s