Button to kick everyone out of database (1 Viewer)

imsuneaik

New member
Local time
Today, 21:38
Joined
Sep 5, 2019
Messages
8
Hi all,


I am trying to create a button to kick users(everyone including myself) out from database. My database is stored in the shared folder on the network. Currently, I realised that my code would only kick myself out. The code is written below


Code:
Option Compare Database
Public Loops As Integer

Private Sub Form_Load()
 Me.TimerInterval = 1000
 Call Form_Timer
End Sub

Private Sub Form_Timer()

Static StartTime As Date

Dim SecondsToCount As Integer
Dim Min As Integer
Dim Sec As Integer

SecondsToCount = 15 'Set this variable to the total number of seconds to count down

If Loops = 0 Then StartTime = Time
 
 Min = (SecondsToCount - DateDiff("s", StartTime, Time)) \ 60
 Sec = (SecondsToCount - DateDiff("s", StartTime, Time)) Mod 60
 Me.TimeLeft.Caption = "Due to maintenance,database will close in " & Min & ":" & Format(Sec, "00")
 Loops = Loops + 1

 If Me.TimeLeft.Caption = "Due to maintenance,database will close in 0:00" Then
   Application.Quit acQuitSaveAll
 End If

End Sub
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 09:38
Joined
Apr 27, 2015
Messages
6,319
Check out the threads in the Similar Threads section of this post (bottom of page)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:38
Joined
Oct 29, 2018
Messages
21,447
Hi. Check out this demo. Hope it helps...
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:38
Joined
Feb 28, 2001
Messages
27,122
This is a common enough question that the "similar threads" and theDBguy both had answers for you. However, I will add a warning: If at any time since the host's last restart someone exited the database unkindly (power fail, reboot, network drop, etc), the back-end's lock file will show the DB as still busy which might or might not interfere with what you are trying to do that requires exclusive access. In this case, you need administrative rights on the server to kill any threads that are holding any file locks on the DB.
 

missinglinq

AWF VIP
Local time
Today, 09:38
Joined
Jun 20, 2003
Messages
6,423
...My database is stored in the shared folder on the network...

Not directly related to your question...but the above statement is kind of worrisome. This is a multi-environment database...so I have to ask...is the database split into a Front End, holding everything except the data...with a copy of it on each user's PC...and the Back End, holding the Tables/Data, residing on the mentioned shared folder on the server?

Linq ;0)>
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:38
Joined
Feb 28, 2001
Messages
27,122
Good point, Linq. If it ain't properly shared, you get chaos really quickly.
 

Users who are viewing this thread

Top Bottom