Results 1 to 7 of 7
  1. #1
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133

    Showing active users in your database.

    How can I print the results from this 4 into a text box



    Code:
    Sub ShowUserRosterMultipleUsers()
      
    Dim cn As Object ' ADODB.Connection
    Dim rs As Object ' ADODB.Recordset
      
    Const adSchemaProviderSpecific As Long = -1
      
      Set cn = CreateObject("ADODB.Connection")
      cn.Provider = "Microsoft.ACE.OLEDB.12.0"
      cn.Open "Data Source=C:\Users\admin\Desktop\Reports.accdb"
      
      Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
        , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
      
    ' Output the list of all users in the current database.
      
      Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
        "", rs.Fields(2).Name, rs.Fields(3).Name
      
      Do While Not rs.EOF
        Debug.Print rs.Fields(0), rs.Fields(1), _
          rs.Fields(2), rs.Fields(3)
        rs.MoveNext
      Loop
      
    End Sub
    Last edited by Forbes; 04-18-2017 at 07:54 PM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Maybe like:

    Code:
    Do While Not rs.EOF
        Me.tbxNames = Me.tbxNames & rs.Fields(0) & ", " & rs.Fields(1) & ", " & rs.Fields(2) & ", " & rs.Fields(3) & vbCrLf
        rs.MoveNext
    Loop
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Pretty nifty, although the only field that shows is the Computer Name Header and I get a debug error of Object required. pointing to your line?

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Likely you copied the example verbatim and don't have a control called tbxNames?
    You should post what you tried or else we're just guessing.

  5. #5
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Code:
    Sub ShowUserRosterMultipleUsers()  
    Dim cn As Object ' ADODB.Connection
    Dim rs As Object ' ADODB.Recordset
      
    Const adSchemaProviderSpecific As Long = -1
      
      Set cn = CreateObject("ADODB.Connection")
      cn.Provider = "Microsoft.ACE.OLEDB.12.0"
      cn.Open "Data Source=C:\Users\admin\Desktop\Reports.accdb"
      
      Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
        , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
      
    ' Output the list of all users in the current database.
    
    
      Forms!frmadmin!txtuserslive = rs.Fields(0).Name
        
        
    frmadmin.txtuserslive = frmadmin.txtuserslive & rs.Fields(0).Name & ", " & rs.Fields(1).Name & ", " & rs.Fields(2).Name & ", " & rs.Fields(3).Name & vbCrLf
      
      Do While Not rs.EOF
    frmadmin.txtuserslive = frmadmin.txtuserslive & rs.Fields(0) & ", " & rs.Fields(1) & ", " & rs.Fields(2) & ", " & rs.Fields(3) & vbCrLf
        rs.MoveNext
      Loop
      
    End Sub

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Maybe prefix with the Forms collection qualifier.

    Forms!frmadmin.txtuserslive = Forms!frmadmin.txtuserslive ...

    or if the code is behind the form, use the Me alias as in my example

    or could use a string variable in place of the textbox in the loop and then outside the loop set the textbox to the variable. See if that makes a difference. If same error then the issue is with the recordset object.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Hey June7,

    Thank you for your input, using the "Forms!" Prefix ended up displaying the desired result. I have the call attached to a command button and when I run it I now see the information I want however the computer name shows but the login name and connected state will not show until I click inside the text box which is weird? But thank you so much!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Email picture not showing for remote users
    By trevor40 in forum Programming
    Replies: 2
    Last Post: 08-12-2016, 01:02 AM
  2. Replies: 2
    Last Post: 11-12-2015, 02:36 AM
  3. Replies: 12
    Last Post: 10-01-2014, 08:17 PM
  4. List of all users from active directory
    By bignate in forum Programming
    Replies: 3
    Last Post: 10-11-2013, 05:53 AM
  5. Active Directory & Access 2010: Importing Users
    By royarellano in forum Access
    Replies: 0
    Last Post: 12-08-2011, 02:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums