Hi There,
'Open the database "C:\example.mdb" in exclusive mode
'Click On Tools/Security/Set Database Passowrd
'Type and re-type the password as "mypass"
'Since we are using mypass as an example
'Open a New VB Project and use the following code
'Dont Forget to referance to "Microsoft ActiveX Data Objects 2.5
'Library
'==============CODE START=====================
Dim AdoConn As New ADODB.Connection
Dim AdoRs As New ADODB.Recordset
Private Sub Form_Load()
On Error GoTo Form_Load_Error
Dim AdoDatabasePath As String
Dim AdoPassword As String
AdoDatabasePath = "C:\Example.mdb"
AdoPassword = "mypass"
If AdoConn.State = 1 Then AdoConn.Close
AdoConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Password='';" & _
"User ID=Admin;Data Source=" & AdoDatabasePath & ";" & _
"Jet OLEDB:Database Password='" & AdoPassword & "'"
On Error GoTo 0
Exit Sub
Form_Load_Error:
MsgBox "Error :" & Err.Number & vbNewLine & "Description: " & Err.Description & vbNewLine & "Procedure: Form_Load" & vbNewLine & "Module Type: Form" & vbNewLine & "Module Name: Form1"
End Sub
'==============CODE END=====================
Have Fun !!
Nasser