Settimer - Application.Quit / .ldb deletion issue

Posted on 2006-05-09
Last Modified: 2012-05-05
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)?
Question by:DangerM0use
    LVL 119

    Accepted Solution

    try the M$ way

    HOW TO: Detect User Idle Time or Inactivity in Access
    LVL 1

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now