Solved

VBA OpenDatabase prompting for password

Posted on 2014-02-04
8
683 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
ID: 39832270
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 27

Author Comment

by:MacroShadow
ID: 39832290
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
ID: 39832392
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 27

Author Comment

by:MacroShadow
ID: 39832407
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
 
LVL 84
ID: 39832443
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 27

Author Comment

by:MacroShadow
ID: 39832582
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
ID: 39832826
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 27

Author Comment

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

Thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Documents and settings folder 30 76
Auto-generated ID's in MS Access 9 45
Programmer 14 48
Can not open the Access Help ? 3 53
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

785 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