Auto Logout of my Database

As it's an unsplit database I assume everyone is running the same file?

Do they all have the same drives setup, will the file path you put in the VBA be correct for them as well as you?
 
I'm sorry that might be the step I missed, I didnt do any VBA or file path. what do I need to do?
 
Then what have you done?

VBA (and an example DB with the VBA in) is all I have provided.

You need to copy (and edit) the VBA in the example or in this thread and use it in the VBA of your database.
 
Oh, so this is the part I need to change
Code:
Private Sub Form_Timer()
On Error GoTo Err_Form_Timer
    Dim strFileName As String

    strFileName = Dir("c:\Enabled.db") <- to this ("c:\Enabled.db") ("[FONT=Times New Roman][SIZE=3]I:\SHAREDatabase1.2.mdb")[/SIZE][/FONT]

    If boolCountDown = False Then
        ' Do nothing unless the check file is missing.
        If strFileName <> "Enabled.db" Then
            ' The check file is not found so
            ' set the count down variable to true and
            ' number of minutes until this session
            ' of Access will be shut down.
            boolCountDown = True
            intCountDownMinutes = 3
            GoTo Warningform
        End If
    Else
        ' Count down variable is true so warn
        ' the user that the application will be shut down
        ' in X number of minutes.  The number of minutes
        ' will be 1 less than the initial value of the
        ' intCountDownMinutes variable because the form timer
        ' event is set to fire every 60 seconds
        intCountDownMinutes = intCountDownMinutes - 1
Warningform:
        DoCmd.OpenForm "frmAppShutDownWarn"
 
c:\enabled.db is a blank file which the VBA checks to see if it exists.

It is not the database name.

Create a file wherever you want, keeping in mind that it has to be accessable by the database for all users (so best to use the same network drive as you know they must have access to that to open the database). Then put the full file path in the VBA in the place of c:\enabled.db

Note it is in more than one piece of code in the database.

Code:
Private Sub Form_Timer()
On Error GoTo Err_Form_Timer
    Dim strFileName As String
 
    strFileName = Dir("[B]c:\Enabled.db[/B]")
 
    If boolCountDown = False Then
        ' Do nothing unless the check file is missing.
        If strFileName <> "[B]Enabled.db[/B]" Then
            ' The check file is not found so
            ' set the count down variable to true and
            ' number of minutes until this session
            ' of Access will be shut down.
            boolCountDown = True
            intCountDownMinutes = 3
            GoTo Warningform
        End If
    Else
        ' Count down variable is true so warn
        ' the user that the application will be shut down
        ' in X number of minutes.  The number of minutes
        ' will be 1 less than the initial value of the
        ' intCountDownMinutes variable because the form timer
        ' event is set to fire every 60 seconds
        intCountDownMinutes = intCountDownMinutes - 1
Warningform:
        DoCmd.OpenForm "frmAppShutDownWarn"

Similar code is in the open / load / current (whichever I used) and will also need the file name / path updating.
 
CBrighton - Thank you very much for working with me on this, and please bare with me while I work though this and get it to work on my end with my users.
Could you please check the VBA below and let me know if I need to change anything else.

I also attached a db to show you what I'm doing

1: Made a folder on the network these all users have access to
Folder name:I:\SHARE\CounterParty Risk\Corey\Enabled.db
Or do I this for the folder name “\\dogwood.com\mspmetro\mn157h\blhm\SHARE\Access Databas\ Database1.2.mdb

2: Run frmSwitchboard to log uses out right away

3: Run frmAppShutdownWarn to give 2 min warning

Is this the correct code to work the above?
Code:
Private Sub Form_Open(Cancel As Integer)
Code:
[SIZE=3][FONT=Times New Roman]   ' Set Count Down variable to false[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   ' on the initial opening of the form.[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   boolCountDown = False[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   Dim strFileName As String[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   strFileName = Dir("I:\SHARE\CounterParty Risk\Corey\Enabled.db")[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   If strFileName <> "Enabled.db" Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       MsgBox "Database being updated, please try again later."[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       Application.Quit acQuitSaveAll[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   End If[/FONT][/SIZE]
 
[SIZE=3][FONT=Times New Roman]End Sub[/FONT][/SIZE]
 
[SIZE=3][FONT=Times New Roman]Private Sub Form_Timer()[/FONT][/SIZE]
 
[SIZE=3][FONT=Times New Roman]On Error GoTo Err_Form_Timer[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   Dim strFileName As String[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   strFileName = Dir("I:\SHARE\CounterParty Risk\Corey\Enabled.db")[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   If boolCountDown = False Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       ' Do nothing unless the check file is missing.[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       If strFileName <> "Enabled.db" Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]           ' The check file is not found so[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]           ' set the count down variable to true and[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]           ' number of minutes until this session[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]           ' of Access will be shut down.[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]           boolCountDown = True[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]           intCountDownMinutes = 2[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]           GoTo Warningform[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       End If[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   Else[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       ' Count down variable is true so warn[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       ' the user that the application will be shut down[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       ' in X number of minutes.  The number of minutes[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       ' will be 1 less than the initial value of the[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       ' intCountDownMinutes variable because the form timer[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       ' event is set to fire every 60 seconds[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       intCountDownMinutes = intCountDownMinutes - 1[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]Warningform:[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       DoCmd.OpenForm "frmAppShutDownWarn"[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       Forms!frmAppShutDownWarn!txtWarning = "Due to database maintenance this application will automatically shut down in approximately " & intCountDownMinutes & " minute(s).  Please save all work and close the database ASAP."[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       If intCountDownMinutes < 1 Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]           ' Shut down Access if the countdown is zero,[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]           ' saving all work by default.[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]           Application.Quit acQuitSaveAll[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]       End If[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   End If[/FONT][/SIZE]
 
[SIZE=3][FONT=Times New Roman]Exit_Form_Timer:[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   Exit Sub[/FONT][/SIZE]
 
[SIZE=3][FONT=Times New Roman]Err_Form_Timer:[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]   Resume Next[/FONT][/SIZE]
 
[SIZE=3][FONT=Times New Roman]End Sub[/FONT][/SIZE]
 

Attachments

Last edited:
Step 1 is correct. The full network path (the second one) is better as it does not rely on all users having the drive assigned to the same letter.

Steps 2 and 3 are not required. Once step 1 is done what will happen is every 60 seconds that the switchboard is open it will check to see if that file exists. If it doesn't exist it will start the 3 minute warning process. It also checks for the existance of the file when the switchboard is opened and if it doesn't exist it will display a messagebox and close the database.


There is no need to interact with the database to kick people out, all you do it rename the file (personally I put a 1 on the end of the file name, but you can edit / delete the file however you want). The time taken to kick people out will vary depending on where each user is within the 60 second timer of the switchboard (timers are based on the time the form was opened on that workstation by that user) so allow about 5 mins to be sure.
 
I use a table with a Logout all user bit in my Back-end database, I have a front end Administration panel from where I can control all my users whose online to which application. (3 front end applications attached with the two different databases)

I can kick-out all or specific user from my applications by double clicking on their names in the Administration panel list.

The basic idea is the logged in user ID will store in the Logged In users table, after that on the other end the user application will check and match that ID from the table and will kick him/her out with a warning message.

For kicking all my user out; I use a bit of ExitAll in the UserLog table, if it is true; a code will run on user front end and will shut the application down.

---- in your case checking for the existence of external file is rather risky and unsafe ----
 
Last edited:
If the file is in a folder where everyone has read access but only I (and other db admins) have write access, what is the risk?

Going by your post I can see your way has more flexibility (as you have the ability to remove specific people), although it doesn't specify whether it also stops people logging in after you kick everyone out. However in an unsplit database I would expect the main reason for kicking people out to be to edit the database, which limits the usefulness of kicking one person out.
 
Give me one good reason why you would have a multi-user none split database.

And I will give you 10 reasons not to.
 
If the file is in a folder where everyone has read access but only I (and other db admins) have write access, what is the risk?

Going by your post I can see your way has more flexibility (as you have the ability to remove specific people), although it doesn't specify whether it also stops people logging in after you kick everyone out. However in an unsplit database I would expect the main reason for kicking people out to be to edit the database, which limits the usefulness of kicking one person out.

Dear CBrighton!
The idea which you use for checking the external file i used before, but then I realise that why I should not use a BIT in my table where aplication will check it and no worry for external file.....

The second part---- I have more then 50 users working on different applications, sometime I want to ban any specific user so I send them Message alert from Admin (developed through Ms-Access) and then free to kick him/her out and block his account.

The third part---- I kick my all user out and no body will be able to open the application if the bit is true, every time any user will try to open the applicaiton he/she will be kickout again with warning message, this I use only if I need my database Compact and repair, or if there is some critical problem or some edition is requird.
 
Give me one good reason why you would have a multi-user none split database.

And I will give you 10 reasons not to.

A good reason is that I love the database no to be splited in parts.;) I believe UNITY is strength :p --- ke ke ke ---
 
  • Data corruption
  • Application corruption
  • One out all out
  • Bad working practice
  • bottlenecks
  • No RBAC
  • Read/Write confilcts
  • No replication
  • etc
  • etc
  • etc
 
Not saying it's a good idea, saying the OP has an unsplit database.
 
Even if I have a single user application sat on the users PC I still give them a split database.

Lets say you need to do some firefighting and you get them to send you their copy to make the changes. That user has then got to wait until you have done the work before they can do theirs. If they continued to wok on their version and you worked on your version and gave them an update, the first thing it would do would be to overwrite all their data as the data is resident in the application and not seperate.

Not a nice thing to tell the end user you have just overwritten a weeks worth of data is it. Or telling them Sorry you cannot do any work until I perform the update and get it back to you.

Now lets say it is a multi user unsplit database sat on a server then you are stopping everyone form doing any work. Need I go on?
 
CBrighton,

What file do I need to edit when you said the following sentence"
There is no need to interact with the database to kick people out, all you do it rename the file (personally I put a 1 on the end of the file name, but you can edit / delete the file however you want)."

Thanks you for staying with me helping me get this figured out
 
Renaming / deleting I:\SHARE\CounterParty Risk\Corey\Enabled.db should kick everyone out.

I put a 1 on the end (i.e. change the file type to .db1) but in reality it doesn't matter what you do to it, as long as there is no file of that name in that folder.
 
ok, so I just put a 1 after the empty folder on the network drive
Enabled.db + 1 = Enabled1.db
 

Users who are viewing this thread

Back
Top Bottom