Solved

VBA OpenDatabase prompting for password

Posted on 2014-02-04
8
714 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 85
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 85
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 85
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

734 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