Link to home
Start Free TrialLog in
Avatar of Lawrence Salvucci
Lawrence SalvucciFlag for United States of America

asked on

Close Access Report using the timer

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

ASKER CERTIFIED SOLUTION
Avatar of Anders Ebro (Microsoft MVP)
Anders Ebro (Microsoft MVP)
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lawrence Salvucci

ASKER

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.
Thank you both for your prompt responses. I appreciate your help!
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
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.