Settimer - Application.Quit / .ldb deletion issue
Posted on 2006-05-09
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)?