A
Andy Morgan
Please can you help?
I am writing some code that will show what users are using a shared database
and in the code I have to put what file I am looking at so I have put the
path in but the file is password protected and when i run the code it is
telling me that the password is incorrect please can you tell me how I can
enter the password into the code.
Please see example of what I have go so far:-
Sub showUserRosterMultipleUsers()
Dim cn As New ADODB.Connection
Dim cn2 As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "Data Source=V:\EMW\SHLSEMW\Staff Information Database\Staff Info
Database.mdb"
cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=V:\EMW\SHLSEMW\Staff Information Database\Staff Info
Database.mdb"
Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-dbdf-00c04fb92675}")
'Output the list of all users in the current database.
Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name
While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rs.MoveNext
Wend
End Sub
The password is for the Staff Info Database.mdb
I am writing some code that will show what users are using a shared database
and in the code I have to put what file I am looking at so I have put the
path in but the file is password protected and when i run the code it is
telling me that the password is incorrect please can you tell me how I can
enter the password into the code.
Please see example of what I have go so far:-
Sub showUserRosterMultipleUsers()
Dim cn As New ADODB.Connection
Dim cn2 As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open "Data Source=V:\EMW\SHLSEMW\Staff Information Database\Staff Info
Database.mdb"
cn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=V:\EMW\SHLSEMW\Staff Information Database\Staff Info
Database.mdb"
Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-dbdf-00c04fb92675}")
'Output the list of all users in the current database.
Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name
While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rs.MoveNext
Wend
End Sub
The password is for the Staff Info Database.mdb