Is it possible to auto close a form after 10 minutes...

J

Jean

Hi,

I am using MS ACCESS 2000. Is it possible to set a timer on upon the form
open and auto close it after 10 minutes ?


Thanks

Jean
 
L

Larry Linson

I am using MS ACCESS 2000.
Is it possible to set a timer on upon
the form open and auto close it after
10 minutes ?

Yes.

Access Forms have a Timer property. You'll have to run it repeatedly and
keep a count in order to measure ten minutes, but when that time is reached,
you can execute a DoCmd.Close to close the Form.

Larry Linson
Microsoft Access MVP
 
J

John C.

In a module, place the following:

Declare Function GetTickCount Lib "kernel32" () As Long


Then, open the properties for your form, set the Timer
Interval to a frequency you want to check for elapsed
time. This is measured in milliseconds, so 1 sec will be
1000. Since you are looking for 10 minutes, I would set
it to 30000 (every 30 seconds).


On your form, place the following in the Form_Load event:

StartTickCount = GetTickCount()


On your form, place the following in the Form_Timer event:

If GetTickCount() - StartTickCount > 600000 Then
DoCmd.Close acForm, Me.Name, acSaveNo
End If
 
H

Howhiareu

You could also use the datediff function instead of using the API.

Set the form's timer interval property to 30000


'Form code module declaration
private FormOpenTime as string

'in form open event
FormOpenTime = now()


'in form's timer event

if datediff("n", FormOpenTime, Now()) => 10 then docmd.clos
acForm, me.name
end if

if there's is any activity that would make you want to extend th
timeout, just update the FormOpenTime as appropriate where appropriate
 

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

Top