Hi Dennis,
To open a password protected Access database you've got to include the
Password in the Properties collection of the ADO connection.
Dim cnData As ADODB.Connection
Set cnData = New ADODB.Connection
With cnData
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=c:\mydatabase.mdb"
.Properties("Jet OLEDB

atabase Password") = "existingpassword"
.Mode = adModeShareExclusive
.Open
End With
Regards,
Gerard O'Donnell
"Dennis" wrote:
> Great code..I needed something like that. Next question, how do you open an
> Access database that is password protected>
>
> "Gerard O'Donnell" wrote:
>
> > Hi Chris,
> >
> > This code will set a password to a previously unprotected Access database:
> >
> > Dim cnData As ADODB.Connection
> > Set cnData = New ADODB.Connection
> > With cnData
> > .Provider = "Microsoft.Jet.OLEDB.4.0"
> > .ConnectionString = "Data Source=c:\mydatabase.mdb"
> > .Mode = adModeShareExclusive
> > .Open
> > End With
> >
> > cnData.Execute "ALTER DATABASE PASSWORD mynewpassword NULL"
> >
> > Regards
> >
> > Gerard O'Donnell
> >
> > "Chris Huddle" wrote:
> >
> > > Does anyone know how to programatically set a password for an Access
> > > Database, preferably in ADO? Thanks! - Chris
> > >
> > >
> > >