Link to home
Start Free TrialLog in
Avatar of DangerM0use
DangerM0use

asked on

Settimer - Application.Quit / .ldb deletion issue

Don't think this is an easy one...

I have an mdb application that is frequently left open throughout the night by its operators, numerous training exercises have failed to persuade people to shut the thing down
and so I decided to incorporate a facility to shut down the system (db) automatically in the event of a client (pc) being left idle for a set period of time.

Idle times where attained via: GetLastInputInfo (user32.dll) / timeGetTime (winmm.dll).

The plan was simple, use a form based timer to establish if a given idle time breached the set threshold; in the event that it did a message was displayed in wordpad and the db
was shutdown (DoCmd.Quit).

Marvellous... er, well no...

Seemingly the form timer event interfered with other aspects of the system, menu actions would not work, claiming that they where 'Not available at this time'; I've tried to over
come this problem, but failed.

So it turned to: SetTimer / KillTimer (user32.dll).

I simply pointed the SetTimer to the 'AddressOf' the local function the form based timer executed.

*** basic interpretation of system init code ***

Call SetTimer(Application.hWndAccessApp, 0, 600000,  Addressof app_quit)

***********************************

This did work, the wordpad message was displayed, the system shut down... but a strange thing, the lock file (.ldb) was not deleted; I've tried calling the quit command from
both a VBA function and a Access Macro, but the problem persists.

Since its not being deleted I'm assuming the mdb is not shutting down correctly.

Any thoughts experts (though 500 points hardly seems adequate)?
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DangerM0use
DangerM0use

ASKER

Sorry I've take so long to reply !!

Microsofts suggestion seems a little flakey !

I've come across a number of options very similar to that of MS but non gave the potential flexibility of a
system timer.

The problem with both those and the MS method was referred to in my previous post. Firing the timer event of a form
every second (as in the MS example) causes unexpected issues with the RunCommand VBA feature.

If the two events collide you are presented with rather nasty and unhelpful error.

In the end I managed to get the original solution to work by introducing a couple of delays, seems that Access did not
previously have time to perform a clean shut down; that being said the link you provided was the recommended way
and as such I feel you're due the points.

Thanks for your help.