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

x
?
Solved

Access 2010 VBA -Run-time error '-2147217843 (80040e4d)':  Authenication failed.

Posted on 2013-11-25
1
Medium Priority
?
3,000 Views
Last Modified: 2013-11-25
Can somebody tell me what is causing the following error...

When the following statement gets executed...

With oConn
        .Open (sConn) 'Open the connection.


The following error occurs...
Run-time error '-2147217843 (80040e4d)':

Authenication failed.



The code...
Option Explicit
Sub Import_AccessData()
    Dim oConn As ADODB.Connection
    Dim oRs As ADODB.Recordset, rst2 As ADODB.Recordset
    Dim stDB As String, stSQL1 As String, stSQL2 As String
    Dim sConn As String
    Dim wbBook As Workbook
    Dim wsSheet1 As Worksheet
    Dim lnField As Long, lnCount As Long
    Dim StrDBPath As String
   
     
     'Instantiate the ADO-objects.
    Set oConn = New ADODB.Connection
    Set oRs = New ADODB.Recordset
   ' Set rst2 = New ADODB.Recordset
     
    Set wbBook = ThisWorkbook
    Set wsSheet1 = wbBook.Worksheets("Test")
     
     'Path to the database.
    stDB = "C:\Users\Ritsick\Documents\Red_Compass\DRA\Full Master Sink 5.accdb"
     
     'Create the connectionstring.
    sConn = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                             "Data Source=" & StrDBPath & ";" & _
                             "Jet OLEDB:Engine Type=5;" & _
                             "Persist Security Info=False;"
       
     'The 1st raw SQL-statement to be executed.
    stSQL1 = "Select Top 1 QUESTIONCODE, REGULATORYANSWER, INPRACTICERESPONSE From vMasterData where QUESTIONCODE = 'GQ-005';"
     
     'The 2nd raw SQL-statement to be executed.
    'stSQL2 = "SELECT * FROM Production_E2"
     
     'Clear the worksheet.
    wsSheet1.Range("A1").CurrentRegion.Clear
     
    With oConn
        .Open (sConn) 'Open the connection.
        .CursorLocation = adUseClient 'Necessary to disconnect the recordset.
    End With
     
    With oRs
        .Open stSQL1, oConn 'Create the recordset.
        Set .ActiveConnection = Nothing 'Disconnect the recordset.
    End With
     
    'With rst2
    '    .Open stSQL2, oConn 'Create the recordset.
    '    Set .ActiveConnection = Nothing 'Disconnect the recordset.
    'End With
     
    With wsSheet1
        .Cells(2, 1).CopyFromRecordset oRs 'Copy the 1st recordset.
    '    .Cells(2, 2).CopyFromRecordset rst2 'Copy the 2nd recordset.
    End With
     
     'Release objects from the memory.
    oRs.Close
    Set oRs = Nothing
    'rst2.Close
    'Set rst2 = Nothing
    oConn.Close
    Set oConn = Nothing
End Sub
0
Comment
Question by:tesla764
[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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39674903
you have this

 stDB = "C:\Users\Ritsick\Documents\Red_Compass\DRA\Full Master Sink 5.accdb"

and used, StrDBPath on the connection

   'Create the connectionstring.
    sConn = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                             "Data Source=" & StrDBPath & ";" & _
                             "Jet OLEDB:Engine Type=5;" & _
                             "Persist Security Info=False;"


change this

 stDB = "C:\Users\Ritsick\Documents\Red_Compass\DRA\Full Master Sink 5.accdb"

with
 stDBPath = "C:\Users\Ritsick\Documents\Red_Compass\DRA\Full Master Sink 5.accdb"
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

660 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