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