I have a database thats is used by about 20 people. I want the first person in that database to run a series of Macros. Is there an easy way to tell if they are the only one in the database?
Thanks.
Thanks.
Dim cnn As ADODB.Connection
Dim strUser As String
Dim rst As ADODB.Recordset
Dim intUser As Integer
Dim varValue As Variant
Const conUsers = "{947bb102-5d43-11d1-bdbf-00c04fb92675}"
Set cnn = CurrentProject.Connection
Set rst = cnn.OpenSchema(Schema:=adSchemaProviderSpecific, SchemaID:=conUsers)
With rst
Do Until .EOF
intUser = intUser + 1
varValue = .Fields(1).Value
If InStr(varValue, vbNullChar) > 0 Then
varValue = Left(varValue, InStr(varValue, vbNullChar) - 1)
End If
strUser = strUser & varValue & vbCrLf
.MoveNext
Loop
End With
strUser = Left$(strUser, Len(strUser) - 2)
MsgBox "There are currently " & intUser & " User(s) logged on to this " & _
"Database, and they are:" & vbCrLf & vbCrLf & strUser, _
vbInformation, "Logged On Users"
'Routine cleanup chores
Set fld = Nothing
Set rst = Nothing
Set cnn = Nothing
Comment