Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STOPPING app & Db on inactivity

Status
Not open for further replies.

MichaelRed

Programmer
Dec 22, 1999
8,410
US
In thread222-794484, there is a discussion re stopping a program programatically. The discussion focues on having a FORM with the attendant timer. This seems to be "OK" for apps which always have a form with the focus.

There is also a cryptic reference to "WaitTable". I have briefly searched for examples which use this (assuming it does not require a Screen.Active.[Form | Report | ... ].

When doing development, there are numerous occurances where the code window (amongst others) is the active XXX and this causes error(s) in the procedures shown.

Further, using a split db operation, there are 'occasions' when the app closes w/o out closing the dbconnection (e.g. Jet engine). This causes some difficulty in doing any maintenance work on the db part.

Anyone know of a way to resonably have a time out process work and not generate an error if the focus is not any of the Scerrn objects? And Which could (again) reasonably be applied to an orphan connection to the db part of the app?

Mike Red



MichaelRed


 
Add a check to your Form_Unload events. Make sure your Command object is closed and not in use. Then you need to make sure your Connection object is closed. Then set it to Nothing. That should take care of 'lingering' connections.
Code:
IF NOT Cmd IS NOTHING THEN SET CMD = NOTHING
IF NOT Cnn IS NOTHING THEN
    If Cnn.State <> adStateClose Then Cnn.Close
    Set Cnn = Nothing
END IF

"...and did we give up when the Germans bombed Pearl Harbor? NO!"
"Don't stop him. He's roll'n.
 
Part of the point is to be able to disconnect without a FORM. Part of the issue is to be able to have a generic timeout to disconnect from the BE and / or shutdown the app even if there is no (active) "Form", (e/g/ when the focus is on the code window).

thanks for the effort



MichaelRed


 
Do you close all your connections as soon as you are finished using them or do you just leave them out there? Only have that Cnn open if your are going to use it. Use it. Then close it immediately.

What is closing the app now?

"...and did we give up when the Germans bombed Pearl Harbor? NO!"
"Don't stop him. He's roll'n.
 
The 'Issue' is that the app is run on a local network accessed via VPN from wherever. If / When the VPN connection is left open and some other event closes the app (improperly) the app connection to the data (seperate) .MDB file remains, thus locking the data. Currently this requires the Net Cops to go and manually close these conections.

Another issue arises, even working on development, the form timer approach requires some form be THE active object. If one wanders into the code window to even peruse the fine work, the scree.object doesn't find ANY object and throws an (un recoverable) error. Thus, to do ANY development (or even review) it is necessary to disable the timeout process ... then, at my age ... it becomes really difficult to remember to re-enable it before uploading changes to the real version of the app.

Bottom line (for me anyway) is that I crave a method (or several) to 'nicely' shut down an app (VB et al) based on user activity (or more properly the lack thereof) without reference/recourse to a form (or other user interface) object. Also, interested in being able to close a db (.MDB) connection from the db (.MDB) when the connection is 'lost'.

These are seperate issues. The first (shut down the APP) needs to be based on user activity, but be aware of any and all activity, active user interface (form, control, long running process, code window changes, ... ). The second would be to disconnect the db (.MDB) when the APP connection to the db is lost.

Thanks again for your efforts and hope this helps ...




MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top