Solved

What is the Excel VB code to extract data from a password protected database?

Posted on 2009-05-11
1
145 Views
Last Modified: 2012-05-06
Hello,

I have written some VB ocde in Excel that will extract data from Access and dump it into a spreadsheet. The problem is that the database is password protected and so therefore when I use the code stated I get an error message stating that the password is invalid. Any help would be appreciated.

Regards,

f19l
Sub IMPORT_PL()
 
Dim DB As Database
Dim DATE_T As Date
Dim EMPLACEMENT, Sql As String
Dim Branch(20) As String
Dim TrnFmly(8) As String
Dim TICKER(200) As String
Dim CURR(200) As String
Dim DPL(200) As Double
Dim MPL(200) As Double
Dim I As Integer
Dim J As Integer
Dim K As Integer
Dim L As Integer
Dim RIEN As Variant
Dim prod_type As String
Sheets("MENU").Select
DATE_T = Cells(3, 7).Value
 
'IMPORT TRADING PORTFOLIOS PL
 
EMPLACEMENT = "O:\Treasury\Daily\Daily Profit and Loss\MARGIN ANALYSIS DATABASE.mdb"
 
       Sql = "SELECT QRY_UNION_DEALS.[Deal No]"
        Sql = Sql & " FROM QRY_UNION_DEALS "
        
        Set DB = OpenDatabase(EMPLACEMENT)
        Set RST = DB.OpenRecordset(Sql)
        
        Sheets("DATA").Select
        Range("B5:S5").Select
        ActiveCell.CopyFromRecordset RST
 
Sheets("MENU").Select
 
End Sub

Open in new window

0
Comment
Question by:f19l
1 Comment
 
LVL 46

Accepted Solution

by:
tbsgadi earned 500 total points
ID: 24355202
something like

Set db = DBEngine.OpenDatabase(".\EMPLACEMENT.mdb",       False, False, ";pwd=password")
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 68
Vb.net 2008 2 60
Access 2003, my txt file export is running backwards 4 52
to transfer string from C lanaguage to VBA 4 66
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

831 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