Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-05-11
1
Medium Priority
?
150 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 2000 total points
ID: 24355202
something like

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

721 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