?
Solved

Using JetUserRoster from Access database

Posted on 2004-10-06
4
Medium Priority
?
289 Views
Last Modified: 2008-03-03
I'm trying to get a list of users who are currently logged into a database from that current database.  I'm developing an Administrator tools menu that displays who is currently logged in to the database.  I've developed a similar application with VB using the code below:

Public Sub GetCurrentUsers(strConnection As String)

On Error GoTo err_trap:

    Dim cn As New ADODB.Connection
    Dim rstUserList As New ADODB.Recordset
    Dim LineItem As ListItem
    Dim i As Integer
   
    i = 0
    cn.Provider = "Microsoft.Jet.OLEDB.4.0;"
    'cn.Properties("Jet OLEDB:System database") = strMDWPath
    cn.Open strConnection
   
    Set rstUserList = cn.OpenSchema(adSchemaProviderSpecific, _
    , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
   
    With Me.ctlListView.ListItems
        .Clear
        Do Until rstUserList.EOF
            Set LineItem = .Add(, , "")
           
            LineItem.SubItems(1) = IIf(Len(rstUserList.Fields(0)) > 0, rstUserList.Fields(0), "")
            LineItem.SubItems(2) = IIf(Len(rstUserList.Fields(1)) > 0, rstUserList.Fields(1), "")
            LineItem.SubItems(4) = IIf(Len(rstUserList.Fields(2)) > 0, rstUserList.Fields(2), "")
            LineItem.SubItems(5) = IIf(Len(rstUserList.Fields(3)) > 0, rstUserList.Fields(3), "False")
            rstUserList.MoveNext
        Loop
       
        rstUserList.Close
        cn.Close
        Set rstUserList = Nothing
        Set cn = Nothing
    End With
   
    Call SetupCurrentUserList

Exit_Sub:
    DoCmd.Hourglass False
    Exit Sub
   
err_trap:
    MsgBox "Error Number: " & Err.Number & vbCr & "Description: " & Err.Description, _
            vbCritical, "ERROR"
    Resume Exit_Sub
End Sub

Public Sub SetupCurrentUserList()
Dim LineItem As ListItem

'Set Status
If Me.ctlListView.ListItems.Count = 1 Then
    Me.txtStatus = "No users connected other than this program."
Else
    Me.txtStatus = Me.ctlListView.ListItems.Count & _
        " users connected (including the connection maintainted by this program)."
End If

'Set Icons
With Me.ctlListView
    For Each LineItem In .ListItems
        If LineItem.SubItems(5) = "True" Then
            LineItem.SmallIcon = "suspect"
        Else
            If CurrentMachineName = LineItem.SubItems(1) Then
                LineItem.SmallIcon = "comp"
            Else
                If LineItem.SubItems(4) = "True" Then
                    LineItem.SmallIcon = "network"
                Else
                    LineItem.SmallIcon = "network_closed"
                End If
            End If
        End If
    Next
End With

End Sub

When I want to populate the user list I call GetCurrentUsers(currentdb.name).  It gives me the following error:

Error Number: -2147467259
Error Description: The database has been placed in a state by user 'Admin' on machine 'HPHome' that prevents it from being opened or locked.

I know the problem is that I am trying to use JetUserRoster to open the datatabase that I currently in.  

Any suggestions on how I can modify the code above to get the user list using JetUserRoster of the database that I am currently in??

Any help would be greatly appreciated...
0
Comment
Question by:jg0069_2002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 2

Author Comment

by:jg0069_2002
ID: 12246106
I think I've figured it out, so I guess I need to withdraw the question.  What I did was the following:

In the GetCurrentUsers subroutine, I replaced:

    cn.Provider = "Microsoft.Jet.OLEDB.4.0;"
    'cn.Properties("Jet OLEDB:System database") = strMDWPath
    cn.Open strConnection

with Set cn = CurrentProject.Connection

and everything worked as planned...
0
 
LVL 85
ID: 12247780
Yes, post a question in Communit Support to do delete the question (with a pointer back to this question)
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12898237
PAQed with points refunded (70)

modulo
Community Support Moderator
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question