Solved

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

Posted on 2009-05-11
1
147 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
Adding to a VBA? 6 85
SLMGR Switches Are Not Working On KMS Host 3 146
Protecting vb6 & .Net code Obfuscation 18 184
VBA: loop recent folder and copy txt file. 8 51
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

730 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