Solved

Close Access Report using the timer

Posted on 2016-08-24
6
41 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

911 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

24 Experts available now in Live!

Get 1:1 Help Now