Solved

VBA OpenDatabase prompting for password

Posted on 2014-02-04
8
669 Views
Last Modified: 2014-02-04
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
Comment
Question by:MacroShadow
  • 4
  • 3
8 Comments
 
LVL 84
Comment Utility
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
 
LVL 26

Author Comment

by:MacroShadow
Comment Utility
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
 
LVL 84
Comment Utility
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
 
LVL 26

Author Comment

by:MacroShadow
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 84
Comment Utility
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
 
LVL 26

Author Comment

by:MacroShadow
Comment Utility
The path is C:\Users\MacroShadow\Desktop\Test\Backend.accdb

Both front and back end are in the same folder. Folder is trusted.
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
Comment Utility
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
 
LVL 26

Author Comment

by:MacroShadow
Comment Utility
mbizup, turns out you were right the problem was caused by Application.CompactRepair using DBEngine.CompactDatabase instead.

Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now