UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Automatic Exit / Close, Access 2016    
 
   
wheeledgoat
post Aug 29 2019, 09:10 AM
Post#1



Posts: 67
Joined: 18-December 18



These [censored] users. Somebody leaves their db open all the time and I can't update the backend. Time to fix.

I started googling about activity timers, but in homage of the K.I.S.S. principle I think I can do one better: since our clinic is never open overnight, I was going to add to the form's timer:

CODE
If Format(date, "HH") = 23 then application.quit

(23 being 11pm on the 24hr clock - so as soon as the timer runs and it's 11:xx pm, the application quits)

Any feedback, pitfalls or better approaches to this?


--------------------
"If you don't make mistakes, you're not working on hard enough problems." -Frank Wilczek

"Success is getting what you want. Happiness is wanting what you get." -B.R. Hayden

Virtue is sufficient for happiness, therefore a sage is immune to misfortune.
Go to the top of the page
 
GroverParkGeorge
post Aug 29 2019, 09:16 AM
Post#2


UA Admin
Posts: 35,881
Joined: 20-June 02
From: Newcastle, WA


That ought to have the effect you anticipate.

I would be VERY sure that all of your users know you plan to implement this well in advance. I would also be sure they acknowledge that that know it will happen and the exact date it will begin.

Good luck.

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
DanielPineault
post Aug 29 2019, 09:23 AM
Post#3


UtterAccess VIP
Posts: 6,900
Joined: 30-June 11



I'd urge you to implement both



They will save you a lot of frustrations.

--------------------
Daniel Pineault (2010-2019 Microsoft MVP, UA VIP, EE Distinguished Expert 2018)
Professional Help: https://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: https://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
wheeledgoat
post Aug 29 2019, 09:37 AM
Post#4



Posts: 67
Joined: 18-December 18



Thanks GPG. Do your cautions stem from fears of unsaved data loss/corruption, or something else?

Also, I'm curious - I could test this myself I suppose, but maybe someone knows: will the timer still run and execute code if the application is open but Windows (7) has timed the user out to the login screen?

--------------------
"If you don't make mistakes, you're not working on hard enough problems." -Frank Wilczek

"Success is getting what you want. Happiness is wanting what you get." -B.R. Hayden

Virtue is sufficient for happiness, therefore a sage is immune to misfortune.
Go to the top of the page
 
GroverParkGeorge
post Aug 29 2019, 09:43 AM
Post#5


UA Admin
Posts: 35,881
Joined: 20-June 02
From: Newcastle, WA


I was thinking backlash from users who come back to work to find that task they'd left open when they went home last night is gone.

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
dale.fye
post Aug 29 2019, 11:32 AM
Post#6



Posts: 161
Joined: 28-March 18
From: Virginia


I generally implement a way to force users off within my code.

I have a table (App_Data) in my database with fields AppProperty and AppValue(string). Two of these records looks like:

AppProperty AppValue
ForceLogoff 0
LogoffIn 10

Then, I have a form (frm_ForceOff) which I load as hidden on startup (usually the 2nd form loaded, right after frm_Startup).
This form has a timerinterval set to 5 minutes, so every 5 minutes, it checks the value of the ForceLogoff record and if it is -1, then is starts makes the form visible and displays a count down (where LogoffIn is minutes) in a label on the form which counts down to 0. This form is a popup, so the user can drag it out of their way while they work on wrapping things up and closing the application.

If the count-down timer gets down to zero, then I:
1. loop through any open reports and close them
2. loop through open forms (in reverse order),
If the selected form is not "frm_ForceOff" then I
a. if the form is dirty, I undo the changes
b. then I close the form
3. Then I perform the application.Quit

This gives me the ability to set the ForceLogoff to 0 or -1, and determine how long until everyone is logged off, keeping in mind that it could be as much a 5 minutes longer than your LogoffIn time because of the Forms TimerInterval being set to 5 minutes.

--------------------
Dale Fye
Microsoft Access MVP 2013-2016
Developing Solutions, LLC
Go to the top of the page
 
wheeledgoat
post Aug 29 2019, 03:57 PM
Post#7



Posts: 67
Joined: 18-December 18



Thanks for those replies - I gained some tools to add to my arsenal, even though not all suggestions apply to this project.

and FYI - my off-the-cuff code above was not correct - I don't think DATE gives a time - changing to NOW works like a charm (I think that's why, anyway)
CODE
If Format(Now, "hh") = "20" Then Application.Quit

--------------------
"If you don't make mistakes, you're not working on hard enough problems." -Frank Wilczek

"Success is getting what you want. Happiness is wanting what you get." -B.R. Hayden

Virtue is sufficient for happiness, therefore a sage is immune to misfortune.
Go to the top of the page
 
tina t
post Aug 29 2019, 07:56 PM
Post#8



Posts: 6,120
Joined: 11-November 10
From: SoCal, USA


just fyi, Date() function does include a time - it just defaults to midnight.

hth
tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    18th October 2019 - 01:23 AM