Solved

Disconnect Access Users

Posted on 2000-04-04
7
549 Views
Last Modified: 2012-08-13
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.
0
Comment
Question by:bharkness
7 Comments
 

Expert Comment

by:OllyW
ID: 2684468
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'
0
 
LVL 1

Accepted Solution

by:
CLoprinzo earned 50 total points
ID: 2687175
Similarly to OllyW's answer, if you know that your users are not using the database after 12 AM then you can use the On Timer event to check the time.  If the time is between 12 and 12:30 AM tell the applcation to shutdown:

Private Sub Form_Timer()
    Dim x As String
    x = Time
    If x > "12:00:00 AM" And x < "12:30:00 AM" Then DoCmd.Quit
End Sub

Keep in mind that this will only work on forms that are open.  If the database is opened by bypassing the start menu or AutoExec then this will not work.  You can set the start options to prevent users from hitting F11, setting all forms to modal, removing "Allow Special Keys" and "Dsiplay Database window" from the startup, and by setting the ChangeProperty "AllowBypassKey" to False... this will disable the shift key bypass.  

Use this method with caution - if a user left a record open and you force it to close it can cause more problems than beating it into their heads to close when they are done.
0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2865378
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
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Expert Comment

by:ozphil
ID: 2895977
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.
0
 
LVL 4

Expert Comment

by:ozphil
ID: 2902708
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.
0
 

Author Comment

by:bharkness
ID: 2907798
Answer accepted
0
 
LVL 4

Expert Comment

by:ozphil
ID: 2909103
12:00AM to 12:30AM? Hey they're my standard working hours. lol.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

705 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