?
Solved

Shutdown Access Database After Certain Idle Time

Posted on 2014-03-25
20
Medium Priority
?
6,837 Views
Last Modified: 2014-03-26
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.
0
Comment
Question by:spaced45
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 4
  • 3
  • +2
20 Comments
 
LVL 58
ID: 39955059
Not sure where the question is in there...

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.
0
 
LVL 1

Author Comment

by:spaced45
ID: 39955073
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.
0
 
LVL 75
ID: 39955102
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
0
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 
LVL 12

Accepted Solution

by:
jkaios earned 2000 total points
ID: 39955121
Try this:


Private Sub Form_Load()
   
   ' start the count down in 3 minutes (60 x 3 = 180)
   Me.Tag = 180
   
   ' interval is every second
   Me.TimerInterval = 1000
   
End Sub

Private Sub Form_Timer()

   On Error Resume Next
   '**********************************
   ' Bail out when count down is zero
   '**********************************
   
   Me.Tag = Val(Me.Tag) - (Me.TimerInterval / 1000)
   
   Me.Caption = "Form will exit in " & Me.Tag & " seconds"
   
   If Val(Me.Tag) <= 0 Then
      DoCmd.Quit
   End If

End Sub

Open in new window

0
 
LVL 1

Author Comment

by:spaced45
ID: 39955126
This is perfect!! Exactly what I was looking for. Hoping to get one last element to this. The example code shows the following:
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

Open in new window


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.
0
 
LVL 1

Author Comment

by:spaced45
ID: 39955136
jkaios,

just noticed your post. I am trying your method now.
0
 
LVL 12

Expert Comment

by:jkaios
ID: 39955137
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.
0
 
LVL 1

Author Comment

by:spaced45
ID: 39955138
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?
0
 
LVL 1

Author Comment

by:spaced45
ID: 39955141
you just answered my question
0
 
LVL 12

Expert Comment

by:jkaios
ID: 39955142
...forgot...if VB6, then replace DoCmd.Quit with Unload Me
0
 
LVL 1

Author Comment

by:spaced45
ID: 39955151
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
0
 
LVL 1

Author Comment

by:spaced45
ID: 39955158
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?
0
 
LVL 1

Author Comment

by:spaced45
ID: 39955165
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.
0
 
LVL 12

Expert Comment

by:jkaios
ID: 39955169
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.
0
 
LVL 1

Author Comment

by:spaced45
ID: 39955180
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.
0
 
LVL 1

Author Closing Comment

by:spaced45
ID: 39955183
Simple and direct!
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 39955419
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.
0
 
LVL 75
ID: 39956678
Dale ... you are late to the two person party :-)

mx
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 39957003
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.
0
 
LVL 75
ID: 39957058
Peter's free app takes ALL of that into account - very elegant. He figured it all out.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question