Solved

Close Access Report using the timer

Posted on 2016-08-24
6
62 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 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

763 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