Dan Waters
dwaters at usinternet.com
Thu Jul 14 15:00:13 CDT 2005
Arthur, This is the code I use to populate a temp table, and then display a list of current users. Note that this is looking at the workgroup file, not the FE or the BE. Private Sub butWhosLoggedIn_Click() If ErrorTrapping = True Then On Error GoTo EH Dim con As New ADODB.Connection Dim rst As New ADODB.Recordset Dim rstData As DAO.Recordset Dim stgData As String Dim stg As String Dim stgFullName As String Dim rstFullname As DAO.Recordset Dim stgUserName As String '-- The user roster is exposed as a provider-specific schema rowset _ in the Jet 4.0 OLE DB provider. You have to use a GUID to _ reference the schema, as provider-specific schemas are not _ listed in ADO's type library for schema rowsets '-- This is partly from MSKB 198755 and is specific to Access 2000 & up con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _ & SystemFolderPath & "\Workgroup\" & SystemWorkgroupName Set rst = con.OpenSchema(adSchemaProviderSpecific, , "{947bb102-5d43-11d1-bdbf-00c04fb92675}") '-- Output the list of all users in the current database. stg = "DELETE * FROM tblCurrentUsers" DoCmd.SetWarnings False DoCmd.RunSQL stg DoCmd.SetWarnings True stgData = "SELECT * FROM tblCurrentUsers" Set rstData = DBEngine(0)(0).OpenRecordset(stgData, dbOpenDynaset) Do While Not rst.EOF stgUserName = Left$(rst.Fields(1), InStr(1, rst.Fields(1), Chr(0)) - 1) If stgUserName <> "Admin" Then rstData.AddNew rstData!ComputerName = Left$(rst.Fields(0), InStr(1, rst.Fields(0), Chr(0)) - 1) rstData!UserName = stgUserName stgFullName = "SELECT Person FROM tblPeopleMain" _ & " WHERE UserName = '" & rstData!UserName & "'" Set rstFullname = DBEngine(0)(0).OpenRecordset(stgFullName, dbOpenSnapshot) rstData!FullName = rstFullname!Person rstData!Connected = rst.Fields(2).Value If IsNull(rst.Fields(3)) Then rstData!Suspect = Null Else rstData!Suspect = Left$(rst.Fields(3), InStr(1, rst.Fields(3), Chr(0)) - 1) End If rstData.Update rstFullname.Close Set rstFullname = Nothing End If rst.MoveNext Loop DoCmd.OpenReport "rptCurrentUsers", acViewPreview rst.Close Set rst = Nothing rstData.Close Set rstData = Nothing Exit Sub EH: Application.Echo True DoCmd.SetWarnings True Call GlobalErrors("", Err.Number, Err.Description, Me.Name, "butWhosLoggedIn_Click") End Sub HTH, Dan Waters -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: Thursday, July 14, 2005 11:14 AM To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] List of users Thanks! One more question on same.... given an ADP connection, I am likely to see redundant names of the individual users. (This is because it is smart and opens new connections to populate combo-boxes etc.) Does this occur in a classic FE-BE setup. Arthur -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust Sent: July 14, 2005 1:57 PM To: Access Developers discussion and problem solving Subject: RE: [AccessD] List of users Using ADO and monitoring the *back end*, you get the users connected to the backend, including your own connection. It doesn't know anything about how the connection was made, just that there is one. Charlotte -----Original Message----- From: Arthur Fuller [mailto:artful at rogers.com] Sent: Thursday, July 14, 2005 10:41 AM To: 'Access Developers discussion and problem solving' Subject: [AccessD] List of users I know that JWC and others have devised methods of detemining the users in an app. My question is this - given that say three front-ends are talking to a single back-end, what does the list of users show. front-end users or back-end users. TIA, Arthur -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com