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 IdleTimeDetecte d subroutine.
Const IDLEMINUTES = 1
Static PrevControlName As String
Static PrevFormName As String
Static ExpiredTime
Dim ActiveFormName As String
Dim ActiveControlNa me As String
Dim ExpiredMinutes
On Error Resume Next
' Get the active form and control name.
ActiveFormName = Screen.ActiveFo rm.name
If Err Then
ActiveFormName = "No Active Form"
Err = 0
End If
ActiveControlNa me = Screen.ActiveCo ntrol.name
If Err Then
ActiveControlNa me = "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 (PrevControlNam e = "") Or (PrevFormName = "") _
Or (ActiveFormName <> PrevFormName) _
Or (ActiveControlN ame <> PrevControlName ) Then
PrevControlName = ActiveControlNa me
PrevFormName = ActiveFormName
ExpiredTime = 0
Else
' ...otherwise the user was idle during the time interval,
so
' increment the total expired time.
ExpiredTime = ExpiredTime + Me.TimerInterva l
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 IdleTimeDetecte d subroutine.
IdleTimeDetecte d ExpiredMinutes
End If
End Sub
Sub IdleTimeDetecte d(ExpiredMinute s)
Dim Msg As String
Msg = "No user activity detected in the last "
Msg = Msg & ExpiredMinutes & " minute(s)!"
MsgBox Msg, 48
Application.Qui t acSaveYes
End Sub 1 5820
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:::mgf0 0 <at> earthlink <decimal-point> net Oakland, CA (USA)
-----BEGIN PGP SIGNATURE----- Version: PGP for Personal Privacy 5.0 Charset: noconv
iQA/AwUBQgKhe4echKq OuFEgEQJvlACfZA sd3RbQwDjMwu1t0 6DyQu9XH4AAn0k1 uagA+hKJsAEzBcI JLD7VoX1r =5rzV -----END PGP SIGNATURE----- jd****@yahoo.co m 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 IdleTimeDetecte d subroutine. Const IDLEMINUTES = 1
Static PrevControlName As String Static PrevFormName As String Static ExpiredTime
Dim ActiveFormName As String Dim ActiveControlNa me As String Dim ExpiredMinutes
On Error Resume Next
' Get the active form and control name.
ActiveFormName = Screen.ActiveFo rm.name If Err Then ActiveFormName = "No Active Form" Err = 0 End If
ActiveControlNa me = Screen.ActiveCo ntrol.name If Err Then ActiveControlNa me = "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 (PrevControlNam e = "") Or (PrevFormName = "") _ Or (ActiveFormName <> PrevFormName) _ Or (ActiveControlN ame <> PrevControlName ) Then PrevControlName = ActiveControlNa me PrevFormName = ActiveFormName ExpiredTime = 0 Else ' ...otherwise the user was idle during the time
interval, so ' increment the total expired time. ExpiredTime = ExpiredTime + Me.TimerInterva l 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 IdleTimeDetecte d subroutine. IdleTimeDetecte d ExpiredMinutes End If End Sub
Sub IdleTimeDetecte d(ExpiredMinute s) Dim Msg As String Msg = "No user activity detected in the last " Msg = Msg & ExpiredMinutes & " minute(s)!" MsgBox Msg, 48 Application.Qui t 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 otherwise.
Most interesting to me is that a reboot won't fix the problem. But if
I just try it again sometime later it will work. Anyone have any
ideas? ...
|
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 doesn't move between controls on a
form (eg, filters on the same control), this is seen as inactivity.
Has anyone successfully modified the code...
|
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 short term, I
would like to find out if the database engine has a time-out
configuration option for idle connections where it would force-close
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 restarted IIS as well.
After 20 minutes of inactivity, sites are still being shut down. Going by
the logs, there is a time stamp if the idle time...
|
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 you do that, when idling
code kicks, an error message from Microsoft "Microsoft has
encountered a problem and needs to close" comes up.
Do you have...
|
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 detect when its containing app pool or
app domain is requesting a shutdown (when it is recycling, for example). I
looked at the Application_End method...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| | |