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
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: