Solved

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

Posted on 2009-05-11
1
148 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
[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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

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