Solved

Close Access Report using the timer

Posted on 2016-08-24
6
31 Views
Last Modified: 2016-08-24
I have some users who have a problem leaving a report opened in Preview mode overnight. Trying to tell them not to do that is like talking to a brick wall sometimes. So what I want to do is have the report close the preview window after a specific amount of time. Can this be done when a report is opened in preview mode? This is how I open the report from my form. This form does stay open but in hidden mode until the user actually closes the report. Then the form is unhidden and they can then close the form also. I want to put a timer on the report so it closes after 5 minutes. So how can I set this up on my report?

Here is the code that opens the report from a command button on my form:

    Dim stDocName As String

    TempVars.Add "strBOForm", Me.Name
    stDocName = Me.cboReport
    DoCmd.OpenReport stDocName, acPreview
    DoCmd.RunCommand acCmdFitToWindow
    Me.Visible = False

Open in new window


And here is the code that unhides the form once the user closes the report preview:

Private Sub Report_Close()
    Forms(TempVars!strBOForm).Visible = True
End Sub

Open in new window

0
Comment
Question by:Lawrence Salvucci
6 Comments
 
LVL 6

Accepted Solution

by:
Anders Ebro (Microsoft MVP) earned 400 total points
ID: 41768572
Well the report has a timer event. IF you set the timer interval equal to 5*60*1000 (5 minutes) and code in the timer event:
Private Sub Report_Timer()
   DoCmd.Close acReport, Me.Name
End Sub

Open in new window

The effect will be that the report closes after 5 minutes. This will work in Preview mode, and also in layout and report mode.

EDIT: And note that your close event will still fire, resetting the visibility of the form, regardless of how the report is closed.
0
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 100 total points
ID: 41768580
You might also be interested in this MSKB article:

ACC: How to Detect User Idle Time or Inactivity
https://support.microsoft.com/en-us/kb/128814

It's a more generic approach to doing this.   When Idle time occurs, most developers add a routine that closes down the app, usually by using the forms and reports collection to close each object that is open.

Jim.
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 41768598
Thank you Anders. That's exactly what I was looking for but I also wasn't sure if the code in the Report Close event would still fire or not.

@ Jim - I actually use that article to close down the DB after a certain amount of time. But I wanted this particular report to close after 5 minutes. The inactivity is set for an hour before it closes the DB all together.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Closing Comment

by:Lawrence Salvucci
ID: 41768599
Thank you both for your prompt responses. I appreciate your help!
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 41768625
lawrence,

if the app is set to automatically close at 1 hour, how can the users keep the report open over night?

Just asking.

Dale
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
ID: 41768634
Some of my "power" users don't have the inactivity timer set for their login. But they're the ones that leave this report open overnight. I don't want to put the inactivity timer on their logins for other reasons. Probably should have explained that in my last post.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now