Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Detect idle time and close a form automatically

Posted on 2003-10-23
5
Medium Priority
?
529 Views
Last Modified: 2012-06-27
Hi

How do I detect if an open form has not had any activity (keystrokes) for say 2 minutes then automatically close the form?

0
Comment
Question by:andrewreilly
  • 3
  • 2
5 Comments
 
LVL 34

Accepted Solution

by:
Mike Eghtebas earned 200 total points
ID: 9612533
Paste following in a standard module, under module tab:

Public TimeVarForm1 As Date

Public Function fnResetTime1()
   TimeVarForm1 =Now()
End Function
------------
In Design view of your Form1, select form and in it time interval enter 10000 to check it every 10 seconds.

In Timer event of Form1 include:

Private Sub Form_Timer()
If (Now() - TimeVarForm1) * 24 * 60 * 2 * 60 > 120 Then
DoCmd.Close acForm, "Form1", acSaveYes
End If

Include following code in OnCurrent event of your form:

fnResetTime1

Regards,

Mike
0
 

Author Comment

by:andrewreilly
ID: 9631727
oops - i accepted too quick

this code is great but only answers half the question.

i want TimeVarForm1 to be reset if a keystroke is detected.  how do i do this?
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 9631763
Call fnResetTime1 anywhere in your application to reset it; if you enter it directly property sheet, use as:

=fnResetTime1()

I think you need if OnActive, OnCurrent, OnKeyPress and LostFocus events of form only.

OnActive: when you come back to a form.
LostFocus: When you leave the form and working on another form.
OnCurrent: When you add a new record and it stays idle.
OnKeyPress: When you press on any key while the form has the focus.

Mike
0
 

Author Comment

by:andrewreilly
ID: 9637479
thanks again Mike
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 9637611
You are most welcome.

Mike
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

783 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