A run-time error occur when Excel open a connection to an Access 2007 table

Lynn100

New Member
Joined
Nov 4, 2013
Messages
19
EXCEL 2007. ACCESS 2007

In Excel, when I click a button the code suppose to connect to an Access
database and retrieve data from a table.

Run-time error '-2147467259(80004005)':Microsoft ODBC Driver could not
find file '(unknow)'.

Con.Open <------ Yellow highlight when the error occur

////////////////////////////////////////////////////////////////////////////////

Private Sub CommandButton1_Click()

Dim Con As New ADODB.Connection
Dim RS As New ADODB.Recordset

'Drive code for access
Con.ConnectionString = "DBQ=C:\To_Be_Used_By_Excel.accdb; " _
& "DRIVER={Microsoft Access Driver (*.accdb)}"

'Open the connection Con.Open
Con.Open <------ Yellow highlight when the error occur
Set RS.ActiveConnection = Con
RS.Open "Select ' from Table_Name"
StartRow = 3

Do Until RS.EOF
'First Field
Cells(StartRow, 4) = RS.Fields(0).Value

RS.MoveNext
StartRow = StartRow + 1
Loop

RS.Close
Set RS = Nothing

Con.Close
Set Con = Nothing

End Sub
 
Last edited:

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