Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timeout / Close a database upon non-use ?

Status
Not open for further replies.

CSHANKY

IS-IT--Management
Jun 4, 2003
20
US
I have created this nice little database and hosted it on a network drive. Since its a multi-user db, many users open the darn thing and conviniently forget to close it. Needless to add, this slows the system and no admin stuff can be done, if needed.

Is it possible that, say, I the typical user (User1) open the db, do what I have to and, forget to close the application.

But my system is smart ! It detects User1 (or any other user for chistssake !) hasn't used it for 3 mins and closes the application, silently.....

Pipe-dream or can be done ?

If I can fix this problem my application would be roaring success !! I need your help gurus....... :)
 
I tried the solution # posted on Thread702-627282 which, alas, did not work for me. Where did I go wrong ?? :((

Disclaimer: I have very little programming knowledge and my IQ is in the semi-moron range. However, I get by with a little help and am committed to making my little application work.

Result: I Get an error message saying:

"The expression On Timer you entered...produced error:Sub or function not defined"

What did I do ?

1. Created a form called frmClosePopUp - unbounded, just like the good doctor asked me to

2. Created a form frmDetectIdleTime, just like the good doctor asked me to

3. Set timer interval to 1000, for frmDetectIdleTime, just like the good doctor asked me to

4. Created an autoexec macro to run frmDetectIdleTime to run hidden, just like the good doctor asked me to

5. Pasted the code into the On Timer event procedure for frmDetectIdleTime, just like the good doctor asked me to


Private Sub Form_Timer()
' IDLEMINUTES determines how much idle time to wait for before
' running the IdleTimeDetected subroutine.
Const IDLEMINUTES = 2
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


 
CSHANKY,

You can't be that slow ... You found this site!
(I found out about it after two years of
DIM - Do It Myself)

Hopefully someone more knowledgeable will post a
confident answer...

I suspect the error has to do with the instruction
near the end:
IdleTimeDetected expiredminutes
is looking for a subprocedure named IdleTimeDetected.
Presumably, it opens frmFromClosePopUp advising the
user that expiredminutes have passed, so you're
closing the database.
Look at the first example in the original thread
as similar code needs to be written.

Indirectly, you can post to a recent thread by the
author - thread705-750613 - and ask for his
assistance.

HTH,
Bob
 
i have to say i tried the code ages ago and didnt work for me either. so created a different way of doing it. this takes time and patience depending on how many forms are in the database.
i created a ghost form that opens on startup. and remains hidden.
i set two unbound controls. on open of the ghost form i set the time InField to Now() and the on timer event sets the time Now to Now() then checks the range between the two.
If its more than 15 minutes a pop up window appears with a message &quot;youre taking too long, do something or i will close&quot; it then has a button to allow the user to stop the quit failing that the timer event kicks in and quits the database.
Each form has code that resets the time InField on open. so as long as the user is navigating around the database and resetting the time in the InField they should not be kicked out. Its a bit grubby but it works. and as i said with only a few forms it doesnt take long to set up.

Be ALERT - Your country needs Lerts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top