Disconnect users

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How disconnect all users connected to database?
I have problem time to time with update, because always is someone connected.
Thanks!
 
Igor G. said:
How disconnect all users connected to database?
I have problem time to time with update, because always is someone
connected.
Thanks!

There is no built-in function that will do this, you have to code it
yourself and it is not a trivial job. If you have coding skills then this
will point you in the right direction:

Private Sub Form_Timer()

On Error Resume Next
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim dtmTimeOut As Date
Dim varType As Variant
Dim varValue As Variant

Set db = CurrentDb()
Set rs = db.OpenRecordset("qtblShutdown")
Do While Not rs.EOF
varValue = rs!Value
If Not IsNull(varValue) Then
Select Case rs!Type
Case "User"
If varValue = fOSUserName() Then
DoCmd.OpenForm "fdlgShutdown", , , , , acDialog
mfTimedOut = True
DoCmd.Close acForm, Me.Name
End If
Case "Computer":
If varValue = fOSMachineName Then
DoCmd.OpenForm "fdlgShutdown", , , , , acDialog
mfTimedOut = True
DoCmd.Close acForm, Me.Name
End If
Case "Time"
dtmTimeOut = varValue
If mdtmTime < dtmTimeOut And Time > dtmTimeOut Then
DoCmd.OpenForm "fdlgShutdown", , , , , acDialog
mfTimedOut = True
DoCmd.Close acForm, Me.Name
End If
End Select
End If
rs.MoveNext
Loop

End Sub

Using this method you can target all users, a specific user or a specific
computer.

Keith.
www.keithwilby.com
 
Thanks;
I just want to disconnect all connected users or computers.
How to modify this code?
 
Igor,

From your post I would guess your database is not split; otherwise, this
would be a trivial problem.
It is rare that the data definition portion of a database changes. By that,
I mean adding, deleting, or changing fields, field definitions,
relationships, or indices. Most updates are in the application portion of a
database. This is the front end which contains forms, reports, macros,
queries, and code. Each user should have a copy of the front end on their
own computer. It should not be shared on a network. Multiple users sharing
a front end is a big contributer to corruption.

Once you have made modifications, then the issue is how to deploy the new
version. There are ways to make the upate automatic or semi automatic, but
before you get into that, I would strongly suggest you split your database
and properly deploy it.
 
Database is splitted, and I just want to disconnect all users when is needed.

Example:
When I click on command button in secret menu all users must be disconnected.
Thanks!
 
Igor G. said:
Thanks;
I just want to disconnect all connected users or computers.
How to modify this code?

You don't need to modify it at all. What you do need is a table
"tblShutdown" with the two fields Type and Value. You then need a query
"qtblShutdown" based on the table. To disconnect all users, put "time" in
the "Type" field and a suitable time (hh:mm) in the "Value" field. So if
it's 14:00 put "14:05" as the time value and see what happens.

The code goes in your form's Timer event and the timer interval should be
set to how often you want the code to check the table (30 seconds is
adequate for me).

You also need this code to run in your main form's Open event so that it
will foil any user's attempt to open it whilst you have it "off-line".

"fdlgShutdown" is just a form that warns the user that the app is about to
close.

HTH - Keith.
www.keithwilby.com
 
Back
Top