How to close a report after it has been open for 1 min in access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report that is based on a query to a linked excel file. Only one
person can open and print report at a time. I would like to be able to
close the report automatically after 60 seconds. This way if someone walks
away from their desk with the report open and sceen locked... the report will
close in a minute anyway.
 
I have a report that is based on a query to a linked excel file. Only one
person can open and print report at a time. I would like to be able to
close the report automatically after 60 seconds. This way if someone walks
away from their desk with the report open and sceen locked... the report will
close in a minute anyway.

Create a form with a timer event. Code the Timer event to close the
report after 1 minute. Also have it close itself after it closes the
report.

Set the Form's Timer Interval to 1000.

Code the Declarations section of the code window:

Option Explicit
Dim dteTime as Date

Code the Form's Open event:
dteTime = Now()

Code the Timer event:

Dim intElapsed as Integer
intElapsed = DateDiff("n",dteTime,Now())
If intElapsed >=1 Then
DoCmd.Close acReport, "ReportName"
DoCmd.Close acForm, Me.Name
End If

Name this form "frmCloseReport"

Open the form from the report's Open event:

DoCmd.OpenForm "frmCloseReport", , , , , acHidden

The report will open the form when it is opened.
The form will close the report in 1 minute and close itself.

That doesn't give a user much time to work with the report.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top