Access passwords

D

dsc

This code:

Dim Pword As Variant
Pword = "garble"
Set myDataBase = OpenDatabase("C:\Download\valid.mdb", , , "PWD=Pword")

Returns a "Not a valid password" error.

I used the Access Tools\Security\Set Database Password menu to set the
password as garble, and when I open the database normally from Access it
works.

Can anybody see what I'm doing wrong?

TIA
 
D

dsc

Okay, well, I figured that one out: you have to provide something for all
four elements in the last argument, or subsequent arguments are ignored.

Dim Pword As Variant
Dim Userio As Variant
Pword = "garble"
Userio = "Admin"
Set myDataBase = OpenDatabase("C:\valid.mdb", _
dbDriverComplete, False, "ODBC;DATABASE=valid;UID=Userio;PWD=Pword;")

Now the password seems to be working, but the ODBC connection failes on
run-time error 3151.

Is there some declaration or reference I have to add to use ODBC, or is the
DATABASE parameter wrong?

This works fine when the password is unset:

Set myDataBase = OpenDatabase("C:\valid.mdb")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top