I am using Access 2002. I downloaded the forms sample database
FrmSmp97.mdb from Microsoft and used the following code in the timer
event of a hidden form in order to close a database if no activity was
detected. I have it set for one minute for testing purposes only.
However, my problem with this code is when the message box pops up and
says "No user activity detected...", you have to actually click the OK
button before the database shuts down. And instead of having just an
OK button, I would like to give the users the option of keeping the
database open if they are actually working in the database, but if no
one is there, I want the database to shut down without having to click
the OK button. Can someone help me modify this code to do this?
Thanks - JD
Private Sub Form_Timer()
' IDLEMINUTES determines how much idle time to wait for before
' running the IdleTimeDetected subroutine.
Const IDLEMINUTES = 1
Static PrevControlName As String
Static PrevFormName As String
Static ExpiredTime
Dim ActiveFormName As String
Dim ActiveControlName As String
Dim ExpiredMinutes
On Error Resume Next
' Get the active form and control name.
ActiveFormName = Screen.ActiveForm.name
If Err Then
ActiveFormName = "No Active Form"
Err = 0
End If
ActiveControlName = Screen.ActiveControl.name
If Err Then
ActiveControlName = "No Active Control"
Err = 0
End If
' Record the current active names and reset ExpiredTime if:
' 1. They have not been recorded yet (code is running
' for the first time).
' 2. The previous names are different than the current ones
' (the user has done something different during the
timer
' interval).
If (PrevControlName = "") Or (PrevFormName = "") _
Or (ActiveFormName <> PrevFormName) _
Or (ActiveControlName <> PrevControlName) Then
PrevControlName = ActiveControlName
PrevFormName = ActiveFormName
ExpiredTime = 0
Else
' ...otherwise the user was idle during the time interval,
so
' increment the total expired time.
ExpiredTime = ExpiredTime + Me.TimerInterval
End If
' Does the total expired time exceed the IDLEMINUTES?
ExpiredMinutes = (ExpiredTime / 1000) / 60
If ExpiredMinutes >= IDLEMINUTES Then
' ...if so, then reset the expired time to zero...
ExpiredTime = 0
' ...and call the IdleTimeDetected subroutine.
IdleTimeDetected ExpiredMinutes
End If
End Sub
Sub IdleTimeDetected(ExpiredMinutes)
Dim Msg As String
Msg = "No user activity detected in the last "
Msg = Msg & ExpiredMinutes & " minute(s)!"
MsgBox Msg, 48
Application.Quit acSaveYes
End Sub 1 5534
Many thanks!
MGFoster wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Don't use a MsgBox. Instead, create a form that will be displayed in place of the MsgBox. Place a Cancel button ("The application will
close in 5 minutes if the Cancel button isn't clicked.") on the form. Set
up a Timer event on the form that will close the db if the user hasn't clicked the Cancel button after the stated interval.
-- MGFoster:::mgf00 <at> earthlink <decimal-point> net Oakland, CA (USA)
-----BEGIN PGP SIGNATURE----- Version: PGP for Personal Privacy 5.0 Charset: noconv
iQA/AwUBQgKhe4echKqOuFEgEQJvlACfZAsd3RbQwDjMwu1t06DyQu 9XH4AAn0k1 uagA+hKJsAEzBcIJLD7VoX1r =5rzV -----END PGP SIGNATURE----- jd****@yahoo.com wrote: I am using Access 2002. I downloaded the forms sample database FrmSmp97.mdb from Microsoft and used the following code in the
timer event of a hidden form in order to close a database if no activity
was detected. I have it set for one minute for testing purposes only. However, my problem with this code is when the message box pops up
and says "No user activity detected...", you have to actually click the
OK button before the database shuts down. And instead of having just
an OK button, I would like to give the users the option of keeping the database open if they are actually working in the database, but if
no one is there, I want the database to shut down without having to
click the OK button. Can someone help me modify this code to do this? Thanks - JD
Private Sub Form_Timer() ' IDLEMINUTES determines how much idle time to wait for
before ' running the IdleTimeDetected subroutine. Const IDLEMINUTES = 1
Static PrevControlName As String Static PrevFormName As String Static ExpiredTime
Dim ActiveFormName As String Dim ActiveControlName As String Dim ExpiredMinutes
On Error Resume Next
' Get the active form and control name.
ActiveFormName = Screen.ActiveForm.name If Err Then ActiveFormName = "No Active Form" Err = 0 End If
ActiveControlName = Screen.ActiveControl.name If Err Then ActiveControlName = "No Active Control" Err = 0 End If
' Record the current active names and reset ExpiredTime
if: ' 1. They have not been recorded yet (code is running ' for the first time). ' 2. The previous names are different than the current
ones ' (the user has done something different during the timer ' interval).
If (PrevControlName = "") Or (PrevFormName = "") _ Or (ActiveFormName <> PrevFormName) _ Or (ActiveControlName <> PrevControlName) Then PrevControlName = ActiveControlName PrevFormName = ActiveFormName ExpiredTime = 0 Else ' ...otherwise the user was idle during the time
interval, so ' increment the total expired time. ExpiredTime = ExpiredTime + Me.TimerInterval End If
' Does the total expired time exceed the IDLEMINUTES? ExpiredMinutes = (ExpiredTime / 1000) / 60 If ExpiredMinutes >= IDLEMINUTES Then ' ...if so, then reset the expired time to zero... ExpiredTime = 0 ' ...and call the IdleTimeDetected subroutine. IdleTimeDetected ExpiredMinutes End If End Sub
Sub IdleTimeDetected(ExpiredMinutes) Dim Msg As String Msg = "No user activity detected in the last " Msg = Msg & ExpiredMinutes & " minute(s)!" MsgBox Msg, 48 Application.Quit acSaveYes End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kerry Neilson |
last post by:
For the past couple of months, Idle won't start when I invoke it. I
am at a complete loss for why this is. When this happens, they python
command line still starts, and python works fine...
|
by: Stephane Belzile |
last post by:
Is there a way I can detect in vb.Net the power has switched to a UPS
unit in case of power failure?
Thanks
|
by: Keith Wilby |
last post by:
The link below:
http://support.microsoft.com/default.aspx?scid=kb;en-us;128814
to the Microsoft KB "Detect Idle Time" article shows how to detect "idle"
time. However, if a user is active but...
|
by: Law |
last post by:
To all the VB master,
i'm new baby in VB. I would like to get ur's advice on how
to stop the application when user is not in use within 5
or 10mins?
Hope to hear VB master soon.
Tks,
Law
|
by: John Gibson |
last post by:
Hi, all.
We are running PostgreSQL 7.2.2 (7.4.1 in a few weeks). We have a
pesky legacy application which periodically leaves open idle
connections. (I know... fix the application). In the...
|
by: Stefan Barlow |
last post by:
On IIS 6, I've disabled idle timeouts and any app pool recycling other than
the 29 hour timed recycle.
I've disabled both on the app pool itself and on all app pools at the server
level. I've...
|
by: ram.ragu |
last post by:
hi
i have problem to calculate idle time of cpu and if idle time is
more then i have to shut down the system. can anyone tell me the idea
to so that please
|
by: LG |
last post by:
Hi,
I have recently used the Microsoft that will detect idle time coding on
my Access database and it works fine as long as you do not add any data
or move from one form to another. As soon as...
|
by: Bubba |
last post by:
Hi,
We have HttpHandlers that can process requests for up to 50 minutes. Those
HttpHandlers are running in an app domain inside the DefaultAppPool. We'd
like the HttpHandlers to be able to...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
| | |