Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    Posts
    2

    Unanswered: Access user list

    Hi

    I would like to have a form will give me a list of users online for the database.


    Thanks

    Chris

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Build a form around something like the following code:

    (ONLY the OpenSchema method is important ...)

    Code:
    Private Sub DetectButton_Click()
    On Error GoTo Err_DetectButton_Click
    
        Dim LoggedUserString As String, LoggedNameString As String
        
        Dim TrgConnect As ADODB.Connection
        Dim TrgRecSet As ADODB.Recordset
        Dim SrcRecSet As ADODB.Recordset
        
        Set TrgConnect = New ADODB.Connection
        Set TrgRecSet = New ADODB.Recordset
        Set SrcRecSet = New ADODB.Recordset
        
        TrgRecSet.CursorType = adOpenDynamic
        TrgRecSet.LockType = adLockOptimistic
        TrgRecSet.CursorLocation = adUseClient
    
        SrcRecSet.CursorType = adOpenForwardOnly
        SrcRecSet.LockType = adLockOptimistic
        SrcRecSet.CursorLocation = adUseClient
        
        TrgConnect.CursorLocation = adUseClient
        '
    '    TrgConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.CurrentProject.Path & Chr(92) & "GMCS Info System.mdb;"
        TrgConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=u:\Mike Owen\Billing Data.mdb;"
    
        SQLString = "DELETE FROM " & ListTbl & ";"
        FormsConnect.Execute SQLString, , adCmdText
        
        Set MyRecSet = TrgConnect.OpenSchema(adSchemaProviderSpecific, , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
        While Not MyRecSet.EOF
    'MsgBox "(0): " & MyRecSet.Fields(0)
    'MsgBox "(1): " & MyRecSet.Fields(1)
    'MsgBox "(2): " & MyRecSet.Fields(2)
    'MsgBox "(3): " & MyRecSet.Fields(3)
            
            LoggedUserString = CleanUpUser(MyRecSet.Fields(1)) & ""
            SQLString = "SELECT [FirstName] & ' ' & [LastName] AS Expr1 FROM UserBillingSettings WHERE ([UserID]='" & LoggedUserString & "');"
            LoggedNameString = LoggedUserString & " (Unknown)"
            SrcRecSet.Open SQLString, MyConnect
            If SrcRecSet.BOF = False Then
                SrcRecSet.MoveFirst
                LoggedNameString = SrcRecSet.Fields(0).Value & ""
            End If
            SrcRecSet.Close
            ' Add the User's name to the list ...
            SQLString = "SELECT * FROM " & ListTbl & " WHERE (1=0);"
            TrgRecSet.Open SQLString, FormsConnect
            TrgRecSet.AddNew
            ' Logged User's Name
            TrgRecSet.Fields(0).Value = LoggedNameString
            TrgRecSet.Update
            TrgRecSet.Close
            MyRecSet.MoveNext
        Wend
        LoadingDelay
    '    LogList.RowSource = ListTbl
    '    LogList.ControlSource = "LoggedUser"
        LogList.Requery
    '    LogList.ControlSource = ""
    '    LogList.RowSource = ""
        
        Set MyRecSet = Nothing
        
        TrgConnect.Close
        Set TrgConnect = Nothing
        Set TrgRecSet = Nothing
        Set SrcRecSet = Nothing
       
    Exit_DetectButton_Click:
        Exit Sub
    
    Err_DetectButton_Click:
        MsgBox Err.Number & ": " & Err.Description
        Resume Exit_DetectButton_Click
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •