Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using JetUserRoster from Access database

Posted on 2004-10-06
4
Medium Priority
?
291 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

618 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