|
|
Title | Use the Data control with a password protected Access 2000 database |
Keywords | Data control, Access, password, DAO |
Categories | Controls, Database |
|
|
Use the Project menu's References command to set a reference to the Microsoft DAO 3.6 Object Library.
Create Database and Recordset objects. Open the database using DBEngine.OpenDatabase. Use the database's OpenRecordset method to create the Recordset. Then attach the Recordset to the Data control's Recordset property.
|
|
Private Sub Form_Load()
Dim file_name As String
Dim db As Database
Dim rs As Recordset
' Open the database.
file_name = App.Path
If Right$(file_name, 1) <> "\" Then file_name = _
file_name & "\"
file_name = file_name & "People.mdb"
Set db = DBEngine.OpenDatabase(file_name, False, False, _
"MS Access;PWD=people")
' Create the Recordset.
Set rs = db.OpenRecordset("People")
' Attach the Recordset to the Data control.
Set Data1.Recordset = rs
End Sub
|
|
|
|
|
|