Solved

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

Posted on 2009-05-11
1
149 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

617 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