spaced45
asked on
Shutdown Access Database After Certain Idle Time
I did a search on my question but I think that the suggestions are going a bit over the top and based on what I have it shouldnt be that difficult but I cant seem to put everything together.
I am trying to place some code on a front end copy of course. I have a linked table on the front end containing the amount of time I am allowing. I have one form called FRM_MGRWRKSPACE with the OnTimer event set at "1000". This form will always be open no ands ifs about it. I have coded it this way.
I already have a form created that I want to pop up when the time has been exceeded with a "timer" control that I want to use as how much time is left before it will time out. All I need want to do is to place something on the OnTimer event to check the eslapsed time and open the my Shutdown form telling them they have "x" seconds before it will shut down.
What makes what I am trying to do simpler then what has been posted is that the code doesnt have to figure out what the idle time is for the form that they are on. Again I have one form that is opened the entire tiem and that opens subform. Any assistance with this would be great thank you.
I am trying to place some code on a front end copy of course. I have a linked table on the front end containing the amount of time I am allowing. I have one form called FRM_MGRWRKSPACE with the OnTimer event set at "1000". This form will always be open no ands ifs about it. I have coded it this way.
I already have a form created that I want to pop up when the time has been exceeded with a "timer" control that I want to use as how much time is left before it will time out. All I need want to do is to place something on the OnTimer event to check the eslapsed time and open the my Shutdown form telling them they have "x" seconds before it will shut down.
What makes what I am trying to do simpler then what has been posted is that the code doesnt have to figure out what the idle time is for the form that they are on. Again I have one form that is opened the entire tiem and that opens subform. Any assistance with this would be great thank you.
ASKER
question was "How do I Shutdown Access Database After Certain Idle Time". Sorry, I left out the "How Do I". I think the link that you provided is going to be able to do the trick. Thank you. I am going to try it out.
One of these two free apps should work for you (or a combination of the two) ... and I guarantee they both work well. In fact, I built an entire Forced Shutdown Module based on Peters Force Shutdown:
Inactive Shut Down Control
http://www.peterssoftware.com/isd.htm
Force Shut Down
http://www.peterssoftware.com/fsd.htm
mx
Inactive Shut Down Control
http://www.peterssoftware.com/isd.htm
Force Shut Down
http://www.peterssoftware.com/fsd.htm
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is perfect!! Exactly what I was looking for. Hoping to get one last element to this. The example code shows the following:
I can simply add a exit database line as it explains but I would like to add a count down to it of maybe 30 seconds. As I mentioned I have a form I created called Shutdown that I would like to show. To make it easy I thinking that instead of opening the dialog window as the example code does if I can fire off my Shutdown form with a countdown control showing the seconds till shutdown. To make it even simpler OR if the Shutdown form fires up its to late, I would like for it to shutdown.
Not sure if you can do that within the dialog window that comes up in the example code thus not needing my shutdown form to fire up but that would be good also.
Sub IdleTimeDetected(ExpiredMinutes)
Dim Msg As String
Msg = "No user activity detected in the last "
Msg = Msg & ExpiredMinutes & " minute(s)!"
MsgBox Msg, 48
End Sub
I can simply add a exit database line as it explains but I would like to add a count down to it of maybe 30 seconds. As I mentioned I have a form I created called Shutdown that I would like to show. To make it easy I thinking that instead of opening the dialog window as the example code does if I can fire off my Shutdown form with a countdown control showing the seconds till shutdown. To make it even simpler OR if the Shutdown form fires up its to late, I would like for it to shutdown.
Not sure if you can do that within the dialog window that comes up in the example code thus not needing my shutdown form to fire up but that would be good also.
ASKER
jkaios,
just noticed your post. I am trying your method now.
just noticed your post. I am trying your method now.
Spaced45, if your Front End app is Access, then just copy and paste the code above and into your "form that is opened the entire time".
If Front End is VB6, simply change Form_Timer() event to YourTimerControl_Timer() where YourTimerControl is the name of the timer control, e.g., Timer1.
Also, you can substitute Me.Tag with a member variable whose scope is accessible thru-out the form.
If Front End is VB6, simply change Form_Timer() event to YourTimerControl_Timer() where YourTimerControl is the name of the timer control, e.g., Timer1.
Also, you can substitute Me.Tag with a member variable whose scope is accessible thru-out the form.
ASKER
jkaios,
Do I set this on the form that I have open the entire time that the user has the app open as I indicated in my initial question?
Do I set this on the form that I have open the entire time that the user has the app open as I indicated in my initial question?
ASKER
you just answered my question
...forgot...if VB6, then replace DoCmd.Quit with Unload Me
ASKER
testing it out so I set me.tag = 60. Just noticed the count down int he title bar. I LOVE IT.
I notice though that the count down stops when I dont have the form active. but at this point i can live with that. still testing
I notice though that the count down stops when I dont have the form active. but at this point i can live with that. still testing
ASKER
DUDE I LOVE IT. Simple. I can deal with this. I am testing out the "Unload Me" now. Should I see any difference in what the user would see?
ASKER
Just to clarify. When I said "dont have the form active" I mean Access active. Noticed it when I was toggling between this site and the app.
Are you using Access as your Front End? If so, then the DoCmd.Quit is the one you're looking for. The Unload Me statement will just close the form that the code is running on.
ASKER
DoCmd.Quit then is what I need. Thank you. I know that having to continue a timer based on either different access forms being open and such require additonal more complex code so I think I am going to leave it at that for now unless you have any suggestions. For now its doing what I want it to do. Might now be within a form an might not be in an in your face way but again it does the trick. Tomorrow, or later today I am going to be posting an additional question dealing with shutdown after checking version number. I have code that is working but having trouble figuring out at what time to run it. Not sure if there is a way for you have the opportunity to answer it but I hope you can assist. Thank you again for all your assistance.
ASKER
Simple and direct!
I use a loop to close all of my forms before I execute the forcelogoff, something like:
Dim frm as form
Dim intLoop as integer
If TimeValue(Now()) > > dtForceLogOff Then
for intLoop = forms.Count - 1 to 0 step -1
set frm = forms(intLoop)
frm.Undo 'undoes any unsaved changes
'frm.AllowClose = true
docmd.close acform, frm.Name
Next
End If
Docmd.Quit
'Allowclose is a form level variable I use to prevent users from closing the main Access window while the application is running. If you don't use that technique, you will not need that line in the code.
This way, each form is closed before the application is logged off.
Dim frm as form
Dim intLoop as integer
If TimeValue(Now()) > > dtForceLogOff Then
for intLoop = forms.Count - 1 to 0 step -1
set frm = forms(intLoop)
frm.Undo 'undoes any unsaved changes
'frm.AllowClose = true
docmd.close acform, frm.Name
Next
End If
Docmd.Quit
'Allowclose is a form level variable I use to prevent users from closing the main Access window while the application is running. If you don't use that technique, you will not need that line in the code.
This way, each form is closed before the application is logged off.
Dale ... you are late to the two person party :-)
mx
mx
Joe,
LOL!
I thought this was an extension of a similar thread that I was one of the first responders to. I had provided a comment on that thread, but had dropped off when someone else took the lead. When I saw the simple docmd.Quit, with no controlled shutdown of the open forms, I thought I would throw my 2cents in.
LOL!
I thought this was an extension of a similar thread that I was one of the first responders to. I had provided a comment on that thread, but had dropped off when someone else took the lead. When I saw the simple docmd.Quit, with no controlled shutdown of the open forms, I thought I would throw my 2cents in.
Peter's free app takes ALL of that into account - very elegant. He figured it all out.
The standard technique to detect idle time is this:
http://support.microsoft.com/kb/128814
which uses screen.activecontrol and screen.activeform
If the user hasn't moved in xxx time, then that's when you'd pop-up your shutdown form and exit after the time elapsed.
Jim.