Detecting keyboard or mouse-click across entire application

I have an Access application and want to run a function called IdleLogoutSet(), if the keyboard or mouse is pressed in any of the forms.  Is there an easy way to do this?
Andy BrownDeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

als315Commented:
You should add your sub to all forms and to all buttons. Events could be: Form_KeyPress and Form_MouseDown.
Look at small sample
DbKM.accdb
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andy BrownDeveloperAuthor Commented:
That was the conclusion I came to also.  Thanks for your help.
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Andy, there is a shortcut for what your trying to do (I think), which is to use ActiveForm and Active Control:

https://msdn.microsoft.com/en-us/vba/access-vba/articles/detect-user-idle-time-or-inactivity

Jim.
1
Dale FyeOwner, Developing Solutions LLCCommented:
Agree with Jim.

When I have a need to check for application idle, I usually put the code in the timer event of a startup form, which gets hidden shortly after startup.  This timer event checks for ActiveForm, and ActiveControl, and if the Active control is a subform, it checks drills down until the ActiveControl refers to a control.  If either the ActiveForm.Name or the ActiveControl.Name retrieved from this process is not equal to the value stored in the timer event, it resets the idle time counter and the strActiveForm and strActiveControl variable values.

This avoids having to put code in every form and control.

Dale
1
Andy BrownDeveloperAuthor Commented:
Thank you everyone - I'll give it a try.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.