Hi JWA, I use the following function that it is in a form with:
- A TextBox named TextUserName
- A TextBox named TextPassword
- A TextBox named TextPath for full database path
- A ListBox named ListUser set to show 3 columns
Note that your machine will appear once in the list because you're connected
to read the list.
Hope I helped.
Mauricio Silva
Public Function WhoIsIn() As Boolean
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim PCName As String
Dim strUserID As String
Dim strUserName As String
Dim strMachineName As String
On Error GoTo UsrMsg_Err
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
'Setup the connection.
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Properties("Jet OLEDB:System database") = "System.mdw" ' Enter full
path
' Just in case there is any
If Nz(TextUserName, "") = "" Then
' cn.Properties("User ID") = Null
' cn.Properties("Password") = Null
Else
cn.Properties("User ID") = TextUserName
cn.Properties("Password") = TextPassword
End If
cn.Open "Data Source=" & TextPath
'Open the connection
Set rs = cn.OpenSchema(adSchemaProviderSpecific, ,
"{947bb102-5d43-11d1-bdbf-00c04fb92675}")
' ================================================
ListUser.RowSource = "Machine;User ID;User Name"
While Not rs.EOF
strMachineName = Replace(Trim(Nz(rs.Fields(0), "")), Chr(0), "")
strUserID = Replace(Trim(rs.Fields(1)), Chr(0), "")
strUserName = Nz(DLookup("MachineUser", "Machine", "MachineID = """
& strMachineName & """"), "")
ListUser.RowSource = ListUser.RowSource & ";" & _
strMachineName & ";" & _
strUserID & ";" & _
strUserName
rs.MoveNext
Wend
WhoIsIn = True
Exit_UsrMsg:
On Error Resume Next
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
Exit Function
UsrMsg_Err:
DoCmd.Beep
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description, vbExclamation
WhoIsIn = False
Resume Exit_UsrMsg
End Function
> Hi All,
>
[quoted text clipped - 4 lines]
>
> regards, Joop