How to open password protected mdb in VB

  • Thread starter Thread starter sanpo
  • Start date Start date
S

sanpo

Guest
:( If an Access database is password protected with say password ‘abcd’, what will the syntax for opening it through VB / VBA:
1. in case of DAO
2. in case of ADODB
3. in case of OpenCurrentDatabase of Access
 
sanpo said:
:( If an Access database is password protected with say password ‘abcd’, what will the syntax for opening it through VB / VBA:
1. in case of DAO
2. in case of ADODB
3. in case of OpenCurrentDatabase of Access


Here's the syntax, I'm not sure if the method you use makes a difference:
OFile = your database's name (with full path)
Pass1 = your database's password

Set db = OpenDatabase(OFile, False, False, ";pwd=" & Pass1)
If Err.Number = 3031 Then
MsgBox "The password you entered is not valid. Please use the correct password for the database."
Exit Function
ElseIf Err.Number = 3051 Then
MsgBox "The database can not be opened. Make sure the Properties of the file are not set to 'Read Only'."
Exit Function
Else
End If

Hope that helps!
 
Further to this, if a database is split and the back end is password protected, how would you supply the password through the front end to access the data ?

Dave
 

Users who are viewing this thread

Back
Top Bottom