vieirasoft 5/1/2011, 18:51
Amigo não estrague o original
Option Compare Database
Option Explicit
Const adhcUsers = "{947bb102-5d43-11d1-bdbf-00c04fb92675}"
Const adhcAllowUsers = "Allow New Users"
Const adhcDisallowUsers = "Disallow New Users"
Sub BuildUserList()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim fld As ADODB.Field
Dim intUser As Integer
Dim strUser As String
Dim varVal As Variant
' Headings
strUser = "Computer;UserName;Connected?;Suspect?"
Set cnn = CurrentProject.Connection
Set rst = cnn.OpenSchema(Schema:=adSchemaProviderSpecific, SchemaId:=adhcUsers)
With rst
Do Until .EOF
intUser = intUser + 1
For Each fld In .Fields
varVal = fld.Value
If InStr(varVal, vbNullChar) > 0 Then
varVal = Left(varVal, _
InStr(varVal, vbNullChar) - 1)
End If
strUser = strUser & ";" & varVal
Next
.MoveNext
Loop
End With
txtUsers = intUser
lboUsers.RowSource = strUser
rst.Close
Set rst = Nothing
Set fld = Nothing
Set cnn = Nothing
End Sub
Private Sub cmdFechar_Click()
DoCmd.Close acForm, Me.Name
End Sub
Private Sub cmdRefreshNow_Click()
Call BuildUserList
End Sub
Private Sub cmdShutdown_Click()
If cmdShutdown.Caption = adhcDisallowUsers Then
CurrentProject.Connection. _
Properties("Jet OLEDB:Connection Control") = 1
cmdShutdown.Caption = adhcAllowUsers
Else
CurrentProject.Connection. _
Properties("Jet OLEDB:Connection Control") = 2
cmdShutdown.Caption = adhcDisallowUsers
End If
End Sub
Private Sub Form_Load()
Me.TimerInterval = Me!txtRefresh * 1000
Call BuildUserList
If CurrentProject.Connection.Properties("Jet OLEDB:Connection Control") = 2 Then
cmdShutdown.Caption = adhcDisallowUsers
Else
cmdShutdown.Caption = adhcAllowUsers
End If
End Sub
Private Sub Form_Timer()
Call BuildUserList
End Sub
Private Sub txtRefresh_AfterUpdate()
Me.TimerInterval = Me!txtRefresh * 1000
End Sub
Faça várias cópias e vá pelos seus dedos, por tentativas e vai ver que vai conseguir.
Abs