Ken,
Not sure what data access method you are using but with ADO it should work if you include in your connection string ";user id = x;password = y;data source =" etc where x is your username and y is your password.
I think with ODBC you select 'advanced' when configuring your datasource and enter the user name and password where prompted.
HTH
Bob
Private Sub Command1_Click()
Dim MyWorkspace As Workspace
Dim SecuredDB As String
Dim slUserName As String
Dim slPassword As String
Dim db As Database
Dim rs As Recordset
'Set the location of the system database
DBEngine.SystemDB = _
"C:\Access\system.mda"
'Create a new workspace object
slUserName = Text1.Text
slPassword = Text2.Text
Set MyWorkspace = DBEngine.CreateWorkspace("New", _
slUserName, _
slPassword)
'Open the database
SecuredDB = _
"D:\ABC.mdb"
'Set db = DBEngine.Workspaces("New").OpenDatabase(SecuredDB)
' Set db = DBEngine.Workspaces.Append MyWorkspace
Set rs = db.OpenRecordset("Names", dbOpenDynaset)
rs.MoveFirst
Label3.Caption = _
"The first record is " & rs.Fields
"LastName").Value
'Close the recordset and the database
rs.Close
db.Close
End Sub
But at the line
'Set db = DBEngine.Workspaces("New").OpenDatabase(SecuredDB)
it gave me the following error: Error: Run-time Error '3265'Item not found in this collection.
And the following line:
' Set db = DBEngine.Workspaces.Append MyWorkspace
isn't working ...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.