Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to link to MSysAccounts table in the MDW file

Status
Not open for further replies.

vblou

Programmer
Sep 17, 2002
9
US
I created a workgroup file (Test.mdw) that I used to secure my mdb file. From my mdb file, I want to link to the MSysAccounts table in the Test.mdw file. The 'Files of type' drop down list in the link popup window only shows 3 types, mdb, mda & mde. How do I link to the mdw file?
 

I guess vblou is trying to get the users/groups defined in the mdw. A propper connection can be used against that file to read from its tables/queries.

vblou what's your intension? I've ready code for doing things like Workgroup Administration without it.
 
vblou,
You can do it with a query using the SQL statement listed below. Be sure to update the path/system database (in italics) before trying to execute the query.

[tt]SELECT *
FROM MSysAccounts
IN 'C:\Program Files\Common Files\System\SYSTEM.mdw';[/tt]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
my intention is to display the account users in the dropdown list in a form.
 
How about this?
Code:
Sub EnymerateUsers()

Dim SysCnn As ADODB.Connection 'The connection object
Dim SysConnection As String    'The connection string
Dim App_Folder As String       'Path to the mdw file
Dim Sys_Dbase As String        'Name of mdw file
Dim Pwr_User As String         'UserID  
Dim Pwr_Pswrd As String        'User's password   
Dim rstEnumerate As ADODB.Recordset

SysConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=" & App_Folder & "\" & Sys_Dbase & _
                ";Jet OLEDB:System database=" & App_Folder & "\" & Sys_Dbase & _
                ";User Id=" & Pwr_User & _
                ";Password=" & Pwr_Pswrd & ";"
Set SysCnn = New ADODB.Connection
SysCnn.Open SysConnection

strSql = "SELECT [Name] " & _
         "FROM MSysAccounts " & _
         "WHERE (Name Not In('Creator', 'Engine', 'Admin)) AND (FGroup=0)" & _
         "ORDER BY 1;" 
Set rstEnumerate = New ADODB.Recordset
With rstEnumerate
    .ActiveConnection = SysCnn
    .CursorLocation = adUseServer
    .Source = strSql
    .Open
    cmbUsers.Clear
    While Not .EOF
        cmbUsers.AddItem .Fields(0) 
        .MoveNext
    Wend
    .Close
End With
Set rstEnumerate = Nothing
SysCnn.Close
Set SysCnn = Nothing

End Sub
 
vblou,
You can use a SQL statement as the row source of a dropdown list.

CMP
 
vblou said:
my intention is to display the account users in the dropdown list in a form.
Personally, I prefer using an API method to access system data, rather than opening a system table directly, if possible.
Code:
Private Sub PopulateDropdown()
    Dim usr As DAO.User
    Dim ws As Workspace
    Dim rowSource As String

    On Error GoTo ErrHandler
    
    Set ws = DBEngine.Workspaces(0)
    
    For Each usr In ws.Users
        rowSource = rowSource & usr.Name & ";"
    Next
        
    cboUsers.RowSource = rowSource

    Set usr = Nothing
    Set ws = Nothing

    Exit Sub

ErrHandler:
    Debug.Print "Error # " & Err.Number & ": " & Err.Description
    Resume Next
    
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top