Knock Out all current User - Access Database

MUKESHY12390

Well-known Member
Joined
Sep 18, 2012
Messages
901
Office Version
  1. 2013
  2. 2011
  3. 2010
  4. 2007
Platform
  1. Windows
Hi All,

Is there any way to knock out all current user from "Access Database"..?

any help would be appreciate.


Thanks,

Mukesh
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I used to have a routine that checked on a network for a file, I used that as an on / off switch. I had Access check in code for the file and if it didn't exist (i.e OFF) everyone was kicked out after a few minutes
 
Upvote 0
thanks for quick reply.

would you mind to explain a bit in details.
 
Upvote 0
OK so the jist of it was

I had a key name file on the network at an identified path location

I had a timer routine that started when Access started

The routine checked the path to make sure a file existed (my test)

If the file dosen't exist then the default was to trigger a routine to shut down all access programs looking at the network.

That allowed me to regain access

when finished updating rename the test file back and then access could be run again

Its in Access 2003, and I haven't used it for years. Not sure where the file is, but will look and post back the code

It was all stuff I skimmed from the internet to make it happen
 
Upvote 0
forgot to mention I had FE and BE, so the lock out was from the BE, FE could be shared at any location
 
Upvote 0
the counter

Code:
Option Compare Database
Option Explicit

Dim iCounter As Integer

Private Sub Form_Load()
    iCounter = 120
End Sub

Private Sub Form_Timer()
    If iCounter > 0 Then iCounter = iCounter - 1
    If iCounter = 1 Then
        Me.lblclock.Caption = "Maintenance Required and/or Updates Required - Hospital Watch will be closing in " _
                              & iCounter & " Second"
    Else
        Me.lblclock.Caption = "Maintenance Required and/or Updates Required - Hospital Watch will be closing in " _
                              & iCounter & " Seconds SAVE Programmed"
    End If
    If iCounter = 0 Then DoCmd.Close acForm, Me.Name, acSaveYes
End Sub

the timer
Code:
Option Compare Database
Option Explicit

Private Sub Form_Timer()
'searches for DataBaseOn.txt every minute.
'if not found, quits Access
    Dim fs
    Set fs = Application.FileSearch

    With fs
        '.LookIn = "H:\Common\Databases" 'Path
        '.LookIn = "X:\GOLD\New Hospital Watch Log" 'Work
        '.LookIn = "\\lasdata\common\GOLD\New Hospital Watch Log\"
        .LookIn = "X:\path\New Watch Log"    'Work
        '.LookIn = "F:\" 'Home
        .SearchSubFolders = False
        .FileName = "DataBaseOn.txt"
        If .Execute = 0 Then
            'display a form with a message
            DoCmd.OpenForm "frmClock", , , , , acDialog
            'get out
            Application.Quit
        End If
    End With
End Sub
 
Upvote 0
thanks a lot !

I have one question, As you mention code will search file every minute what happen in scenario where some other macro already running in same database ( some macro take 9 hrs to update the entire database).?
 
Upvote 0
Then you probably should limit the exercise to preventing anyone else from logging in. Likely you cannot affect a database in this condition since (as you've probably noticed before, Windows will indicate Access is "Not Responding" - because it's busy.

If you have a user table with logged in flag and routines to set/unset it, you could know who you need to speak to about any running processes they may have. However, if the user has an abnormal db shutdown, they can leave that setting True, so it's not fool proof.

For what it's worth, I also used a file approach, but the FE only exposed the button to initiate a lock out if you had the admin profile. This button created a hidden file and set the button caption from Start Lockout to End Lockout so you'd know what state that was in. End Lockout killed the file. Which one ran depended on the caption. The startup routine checked for the file and a hidden form with a timer event had one small snippet of code to check if the file existed. That form load event got the timer 'frequency' value from a table of db parameters so I could easily change it without having to delve into form code. In another db, I did have a mix of this and along with 'interval' and 'start' values (so when the file is found, every n minutes deduct x minutes from the start value); the result being assigned to TimeRemaining variable in code. When it got to zero or less, I initiated Application.Close. Of course, this code had to be in every FE.
 
Upvote 0
thanks a lot !

I have one question, As you mention code will search file every minute what happen in scenario where some other macro already running in same database ( some macro take 9 hrs to update the entire database).?

It was only ever working with small data (for me), the reason I had to create something that I had never seen or been taught was people miles away on an unidentified IP, would leave their copy open, preventing me doing maintenance and helpfully the application had been installed with enterprise so user name was generally the same everywhere
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,692
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top