Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 893
  • 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
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

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