• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 802
  • Last Modified:

VBA OpenDatabase prompting for password

Hi folks,

This one got me stumped, Using the following code the user is prompted for a password even though it is supplied in the code.

1. What causes it?
2. How to prevent it?

Set dbs = OpenDatabase(Name:=strBackEnd, Options:=False, ReadOnly:=False, Connect:="MS Access;PWD=1234")

Open in new window

0
MacroShadow
Asked:
MacroShadow
  • 4
  • 3
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Assuming this worked previously:

-- Password is wrong, or has been changed.

-- You're pointed to the wrong backend (especially on Win7 with virtualized folders)

-- Backend is corrupt/faulty
0
 
MacroShadowAuthor Commented:
Never got it to work in the code.

1. Password is correct (database will open when the same password is supplied to the prompt).
2. strBackEnd is the correct backend.
3. Backend works fine when opened manually.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Are you using the Workspace object to do this:

Dim ws As DAO.Workspace
Dim dbs As DAO.Database

Set ws = DBEngine.Workspaces(0)
Set dbs = ws.OpenDatabase(blah blah)

Just for kicks, you might try it using different syntax:

Set dbs = OpenDatabase(strBackEnd, False, False, "MS Access;PWD=1234")

Named arguments shouldn't have anything to do with this, of course, but it's worth a shot.

What operating system are you on?

What environment are you using when running this code (i.e. Access, Excel, etc)?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
MacroShadowAuthor Commented:
No I'm not using the Workspace object (but I did try and it didn't make a difference).

As you expected removing the named arguments didn't help.

Running it from Access 2010 on Windows 7.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
What's the path of the database (i.e. strBackEnd)? Curious as to exactly where, on the machine, it resides.

Got everything in a Trusted Location (the file at strBackend, as well as the FE where you're running the code)?
0
 
MacroShadowAuthor Commented:
The path is C:\Users\MacroShadow\Desktop\Test\Backend.accdb

Both front and back end are in the same folder. Folder is trusted.
0
 
mbizupCommented:
What is the full code in that procedure?

Have you stepped through the code to verify that it is indeed that particular line causing the password prompt and not a later line of code referencing the database?
0
 
MacroShadowAuthor Commented:
mbizup, turns out you were right the problem was caused by Application.CompactRepair using DBEngine.CompactDatabase instead.

Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now