JWColby
jwcolby at colbyconsulting.com
Thu May 3 08:37:52 CDT 2007
>I'm a tad concerned about the timer continuing to operate while the user is using the app. Won't it interfere with things? YES, and that is one of the major design flaws in Access. Timers ticking cause issues with forms flickering, code compile errors for the developer in design view etc. Unfortunately that is what we are given to work with. About the only thing that can be done is to try and set the tick to as long an interval as possible. For example, if the developer wanted to know that a person hasn't done anything in 10 minutes then set the timer to every 10 minutes. This is certainly preferable to setting it to every 10 seconds of course. Fire the timer at the slowest possible rate to perform the task. As for seeing the mouse move, you are correct. Probably a very simple form wrapper would be "good enough". If the mouse is waved around, it is almost certainly going to fire form mouse moves. These kinds of wrappers are easy to set up if they are simple. In the form header dimension the class: Dim fclsFrm as clsFrm In the OnOpen of the form: Private Sub Form_Open(Cancel As Integer) 'SET the class instance Set fclsFrm = new clsFrm 'Pass in a reference to the form using an Init method of the class: fclsFrm.Init Me 'Turn on the event sink for the mouse move Me.OnMouseMove = "[Event Procedure]" 'Turn on the event sink for the Close Event me.OnClose = "[Event Procedure]" End Sub In the code editor, do an Insert / class module. In the class header, dimension a form variable withevents: Option Compare Database Option Explicit Dim withevents mFrm as form 'Now create an Init method with a form parameter Function Init(frm as Form) set mFrm = frm End function 'You have just captured a pointer to the form. Now the class has to sink the mouse move: Private Sub mfrm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) gdteLastActivity = now() End Sub 'You also need to clean up the pointer to the form in the class as the form closes so create a sink for the OnClose as well: Private Sub mfrm_Close() set mfrm = nothing End Sub Save the class as clsFrm. Create a global variable gDteLastActivity in a module somewhere. Voila, you now have a class sinking the form's mouse move event and setting a global variable with the time of the mouse move. The timer form should be simple enough that I do not need to go into that. OTOH, IF there are no forms using the form timer already, then you could have the form wrapper class itself do the monitoring. In the Init() method add: Function Init(frm as form) 'other stuff already here 'Set the timer interval to 10 minutes (10 * 60,000 milliseconds) me.TimerInterval = 10 * 60 * 1000 'Turn on the timer event sinking me.OnTimer = "[Event Procedure]" End function 'In clsFrm add a timer sink Private Sub Form_Timer() 'THIS IS PSEUDOCODE!!! if now() - gdteLastActivity > 10 minutes then docmd.openform "frmAskAboutActivity" endif End Sub Using something like this, timers would only run if a form is actually open of course. That may be an advantage in some cases (you don't want to shut down if they don't actually have a form open) because there would be no timer ticks unless a form was open. Classes and withevents! Ya gotta love 'em. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: Thursday, May 03, 2007 8:34 AM To: Access Developers discussion and problem solving Cc: asanga at xplornet.com Subject: Re: [AccessD] Lock-screen inside an Access app Thanks, JC. My friend is an occasional visitor to this group, and has been here enough to know some of the more frequent names. I told him when he asked that you and/or Shamil would know how to do this. I'm forwarding your message to my friend now. I'm not sure how, in the absence of an entire framework, he should create the wrappers for mouse-move and click, but maybe the keydown will be enough for his requirements. So it would work something like this? Form is hidden. Timer sees no keystrokes for say 10 minutes, then makes the form visible in dialog mode. Counts password attempts to three. If still no valid password, then Application.Shutdown; else hide the form and let the user proceed. I'm a tad concerned about the timer continuing to operate while the user is using the app. Won't it interfere with things? On the other hand, I can't think how else it might work, since the user could conceivably walk away leaving the cursor in the middle of some field while he was adding a new customer or something. Arthur On 5/3/07, JWColby <jwcolby at colbyconsulting.com> wrote: > > The issue here is "minutes of inactivity". In order to measure time > in Access a form somewhere has to be running a timer. > > There is absolutely nothing AFAIK built in to Access that "measures > activity". In order to measure activity... You have to define activity. > Mouse movements? Keystrokes? These are the two most common. > Keystrokes are fairly easy, you intercept the key down and set a "last activity time" > global date variable. Mouse movement however is much harder. > > For that you will need a framework which uses class wrappers around > forms and controls (or at least the form). Having that you can sink > the mouse move event for the form and controls and set the same global > "last activity time" global date variable. > > Having a "last activity time" variable you can now use that timer tick > I mentioned in the second sentence to see how long since the last activity. > > All in all not a 10 minute project, but it is doable. > > John W. Colby > Colby Consulting > www.ColbyConsulting.com > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur > Fuller > Sent: Thursday, May 03, 2007 7:53 AM > To: Access Developers discussion and problem solving > Subject: [AccessD] Lock-screen inside an Access app > > A friend asked me how he could put a Windows-like screen lock (that > asks for a password) inside an Access app. He's thinking that it's a > hidden form that then appears after x minutes of inactivity and wants > a password before letting the user back into the app. Presumably it > would shut the app down with no valid password. > > Does anyone have an idea how to do this? > > TIA, > Arthur > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com