Solved

Using JetUserRoster from Access database

Posted on 2004-10-06
4
281 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
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 84
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

810 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