Link to home
Start Free TrialLog in
Avatar of bharkness
bharkness

asked on

Disconnect Access Users

I have an aplication (written in VC++ 6.0) which will compact and repair Access databases.
I scheduled the app to run in the wee hours of the morning.
The problem is that users of the Access databases sometimes do not shut down their client apps and remain connected to the database.
No amount of pleading or threats seems to help!
Is there some way to programmatically disconnect users from an access database before attempting to repair or compact the database.
Avatar of OllyW
OllyW

There is no built in way to disconnect an Access user because they are, after all just sharing a file. You force the file server to disconnect them from the pipe (using apis), but disconnection from an access database can have very nasty results if the user has a record open for update.

Another idea might be to make the Access application intellegent on each of the clients. Make a table in the database called 'Shutdown' or similar. When you want to shutdown the clients, use code to add a predefined message to the table. On the client database, open a hidden form when the application starts up (could use a AutoExec macro). On this form, set the timer to something like 10000 (10 minutes). On the on_timer event query the shutdown table. If the message is there, call a routine to shut the forms/database/Access. Keeping to polling interval large will cut down on unnessary network traffic.

You call even popup a countdown timer until shutdown, to warn the users to save work if you wanted to do it during the daytime.

I know this is not as nice as it could be on some database platforms, but hey, using the Access philosophy, 'It'll do'
ASKER CERTIFIED SOLUTION
Avatar of CLoprinzo
CLoprinzo

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
You say, "No amount of pleading or threats seems to help!"

Maybe you should stop threatening, and really beat them...

If you set the app to open a form and keep it hidden when the app is opened, you can use its timer event as others have suggested.  That would not rely on the user to have a certain form open, as it would always be open . . .

It would be nice to be able to use Windoze's timer event, but Access does not support callback functions...

Brian
There is a .dll which enables one to identify users/machines connected to a database.

That could be the starting point point for providing some control over when to begin compact operations etc.

The dll is MSLDBUSR.DLL and is avaialable free from microsoft. It comes in a zipp file complete with a demo database application.
CLoprinzo

By posting an inconclusive answer you effectively 'hide' the question in the 'pending evaluation' section, which pisses the hell out of the questioner.

Let the questioner decide. It's  the courteous ethic here.
Avatar of bharkness

ASKER

Answer accepted
12:00AM to 12:30AM? Hey they're my standard working hours. lol.