Solved

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

Posted on 2009-05-11
1
143 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
Comment Utility
something like

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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now