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
> How To Run A Function At Application Exit?, Access 2010    
 
   
fizzy1
post Sep 7 2016, 12:58 PM
Post#1



Posts: 457
Joined: 26-May 11



Hi,

I want to run a particular function when a user closes my database application (I want to push a value into a table timestamping their exit).

Is there somewhere that I can reference the imminent closing of the app, and then trigger an event?

(I do have one form that remains open, and can't be closed by the user, but I also have some code that if a user logs out and logs in again that form is closed & re-opened, which throws a spurious trigger, so I'd prefer to avoid sing that form's OnClose event.)

Thanks,
Toby.
Go to the top of the page
 
theDBguy
post Sep 7 2016, 01:03 PM
Post#2


Access Wiki and Forums Moderator
Posts: 71,202
Joined: 19-June 07
From: SunnySandyEggo


Hi Toby,

One possible approach is to use a "flag" with your "Exit" button. Then, when your form closes, you can check if the user wanted to exit or just log off.

Hope it makes sense...
Go to the top of the page
 
LPurvis
post Sep 7 2016, 01:16 PM
Post#3


UtterAccess Editor
Posts: 16,085
Joined: 27-June 06
From: England (North East / South Yorks)


I'd agree with DBGuy, you can certainly cause your existing instance form to behave differently... Or you could just opt for having another form permanently open until the application instance ends (such a form is usually opened invisible/hidden and persisted primarily for this purpose - or persisting a connection or its timer event.)

Of course, you could also throw your weight behind asking MS for more application events.
https://access.uservoice.com/forums/319956-...on-window-close

If that's something that appeals. :-)

Cheers
Go to the top of the page
 
fizzy1
post Sep 7 2016, 06:08 PM
Post#4



Posts: 457
Joined: 26-May 11



Thanks gents. Initially I took the route of making a hidden form that opens at startup, and fires off the timestamp operation in it's OnClose event.

However, that made me feel a little dirty, having to make a form just as a workaround no matter how easy or sensible it is, so I reworked some of the code that was driving my Dashboard form to close and open on a change of user, and put the timestamp operation in its OnClose event. Basically what I originally said I preferred not to do wink.gif But that was the cleanest, and it forced me to address one of the little niggles I'd had with it anyway (the close then open thing).

I did vote on that petition to get some application-wide events added smile.gif

So in the end it worked out, thanks for the advice.

Thanks,
Toby.
Go to the top of the page
 
theDBguy
post Sep 7 2016, 08:28 PM
Post#5


Access Wiki and Forums Moderator
Posts: 71,202
Joined: 19-June 07
From: SunnySandyEggo


Hi Toby,

Glad to hear you got it sorted out. Good luck with your project.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    11th December 2017 - 03:51 PM