Solved

Close Access Report using the timer

Posted on 2016-08-24
6
78 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

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 58

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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 1

Author Closing Comment

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

Expert Comment

by:Dale Fye
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

626 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