Run-Time Error Opening Access from VBA in Excel

rootdown42

Board Regular
Joined
Jun 8, 2005
Messages
93
I am on my first attempt to use vba to open an Access database from an Excel file and write the data in the Excel file to the database. Not surprisingly I've run into difficulty.

I'm using ADO to perform the commands. The code gives me "run-time error -2147217843 (80040e4d) Authentication failed" when I get to the last line in the code below. I don't understand how there is an authentication error when I have absolutely no protection on this database at all.

Code:
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim intFiscYr(1 To 7) As Integer ' values for fiscal year
    Dim intResponse As Integer
    Dim myFlag As Boolean
    myFlag = False
    
    ' connect to the Access database
    Set cn = New ADODB.Connection
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
        "\\Mke01sfile01\Data\960\Systems and Applications\Forecasting\Rebate-Lapsing Data\" & _
            "Consumer Rebate Database\Consumer Rebate Database.mdb;"

Can someone tell me what the problem is? Any help is appreciated.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Alright, I guess I'm a little slow. Turns out the error was a result me not coding the file path statement correctly. If anyone else stumbles upon this error, make sure to include "Data Source=..." before the file path in your connection.open statement.

Code:
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source=\\Mke01sfile01\Data\960\Systems and Applications\Forecasting\Rebate-Lapsing Data\" & _
            "Consumer Rebate Database\Consumer Rebate Database.mdb;"
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top