Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    204

    Unanswered: Code question, db from code bank...user login

    Hello,

    I just tried this database in the code bank to view which users are in a database.....I am using access 2007.

    When I changed the code to the path of the database I want to view (it is on a shared drive) it gave me this error:

    Error # 3705 was generated by ACODB.Connention
    Description: Operation is not allowed when the object is open.
    Please contact the database administrator.

    Do you know what I did wrong?


    Here is the code I used:

    Code:
    Private Sub ShowUsers()
    
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        Dim i, j As Long
    
        Set cn = CurrentProject.Connection
        'If youy want to reference a db that is NOT the one you are in
        'then use the following code w/out the 's and change the file paths.
            cn.Provider = "Microsoft.Jet.OLEDB.4.0"
            cn.Open "Data Source=M:\Activity Log\USE THIS ONE Minooka Activity Log Database.accdb"
            cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
            & "Data Source=M:\Activity Log\USE THIS ONE Minooka Activity Log Database.accdb"
    
        ' The user roster is exposed as a provider-specific schema rowset
        ' in the Jet 4.0 OLE DB provider.  You have to use a GUID to
        ' reference the schema, as provider-specific schemas are not
        ' listed in ADO's type library for schema rowsets
    
        Set rs = cn.OpenSchema(adSchemaProviderSpecific, , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
    
        Dim str1 As String, str2 As String, str3 As String, str4 As String
    
        str1 = rs.Fields(0).Name & vbNewLine & vbNewLine
        str2 = rs.Fields(1).Name & vbNewLine & vbNewLine
        str3 = rs.Fields(2).Name & vbNewLine & vbNewLine
        str4 = rs.Fields(3).Name & vbNewLine & vbNewLine
        
        While Not rs.EOF
            str1 = str1 & Nz(rs.Fields(0), "NULL") & vbNewLine
            str2 = str2 & Nz(rs.Fields(1), "NULL") & vbNewLine
            str3 = str3 & Nz(rs.Fields(2), "NULL") & vbNewLine
            str4 = str4 & Nz(rs.Fields(3), "NULL") & vbNewLine
            rs.MoveNext
        Wend
    
        Me.TxtBox1 = str1
        Me.TxtBox2 = str2
        Me.TxtBox3 = str3
        Me.TxtBox4 = str4
    
        rs.Close
        Set rs = Nothing
        cn.Close
        Set cn = Nothing
    
    End Sub

  2. #2
    Join Date
    Oct 2009
    Posts
    204
    Bump......

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    this bit of code does nothing about login
    try looking for the vode supplied by PKStormy
    or google 'dev ashish api'
    or API: Get Login name
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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