Apply the boot

Sully38

Board Regular
Joined
Mar 9, 2004
Messages
167
I have a db that is being used by about 20 people. On days of updates I am being driven crazy getting everyone to logout of db. Is there an Auto boot feature for Access? Is it possible to tell who I kicked out as well?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
If you want to see who is in the database, the .ldb file in the same folder as the DB has that information.
If you want to boot them out, you could use this:

1. An empty text file in the same folder, called DataBaseOn.txt
2. A startup form that opens in Hidden mode, which (a) opens your main menu and (b) looks periodically for the text file. If it is not found (eg you changed the name to DatabaseOff.txt), the DB closes with a message.
Code:
Private Sub Form_Load()
    DoCmd.OpenForm "Title Page", acNormal
End Sub

Private Sub Form_Timer()
    Dim sPath As String
    Dim i As Integer
    Dim dStartTime As Double
    Dim dEndTime As Double
    sPath = CurrentProject.Path
    With Application.FileSearch
        .NewSearch
        .LookIn = sPath
        .SearchSubFolders = False
        .FileName = "DatabaseOn.txt"
        .MatchTextExactly = True
        .fileType = msoFileTypeAllFiles
        If .Execute() > 0 Then
            'keep database going
        Else
            'turn off for maintenance
            dStartTime = Timer
            MsgBox "This database will be closing for maintenance"
            DoCmd.Quit
        End If
    End With
End Sub

Adjust the interval using the Timer property of the form, which is entered in milliseconds. eg, 60000 is 1 minute.

Denis
 
Upvote 0
That worked really well thank you .. and not to be mean but it felt good hearing the reactions as the db closed 8-)
 
Upvote 0
I'm semi new to Access. Would I paste this code in with the code for the form that comes up when the database is launched? Also, when I create a form, I don't see a selection for timer properties. I really love the idea of this code if I could only get it to work for me.

Thanks in advance.
 
Upvote 0
Would I paste this code in with the code for the form that comes up when the database is launched?
Yes. In the form's Properties (in Design view), go to the Events tab. Near the bottom you will see On Timer and Timer Interval.
First, On Timer...
Double-click the blank line so you see Event Procedure. Click the Builder (...) button at the end of the row and you will be in the code window. Paste the Form_Timer code in there.

If you want to launch another form when you load this one, create an On Load event and insert the Form_Load code. Change the name of the second form to suit.

Also, when I create a form, I don't see a selection for timer properties.
This is the Timer Interval line. Enter the desired interval as I described in my previous post.

Denis
 
Upvote 0
I had some feedback re opening a form in hidden mode. Here's how to do it in code...
Code:
DoCmd.OpenForm "frmMonitor",,,,,acHidden
You attach that to the Load event of your startup form (Menu, Switchboard, whatever) and frmMonitor will open in the background.

Denis
 
Upvote 0
Thanks for the followup, Denis.

Any idea why I get a
Run-time error 5; Invalid procedure call or arguement
on
<code>
.fileType = msoFileTypeAllFiles
</code>
I rem'd it out
 
Upvote 0
I'm not sure why it errored out -- often this happens if a library isn't referenced, and in that case the number represneted by the constant has to be used instead. I'll follow it up, but commenting the line shouldn't affect anything.

Denis
 
Upvote 0
Update -- Create a reference to the Microsoft Office Library if you don't already have one. That should remove the error, because FileSearch is part of the Office Library.

Denis
 
Upvote 0

Forum statistics

Threads
1,224,801
Messages
6,181,047
Members
453,014
Latest member
Chris258

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