R
ryguy7272
I was just watching the video here:
Trying to follow the example but some of the text is fuzzy. I typed the
following VBA into Excel:
Sub Rectangle1_Click()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
'Drive code for Access
con.ConnectionString = "CBO=C:\Temp\MyAccess.accdb:" & _
"Driver = (Microsoft Access Dirver (*.accdb));"
'Open DB Connection
con.Open
Set rs.activeconnection = con
rs.Open "Select * from SharePrices"
StartRow = 3
Do Until rf.EOF
'First Field
Cells(StartRow, 4) = rs.Fields(1).Value
'Second Field
Cells(StartRow, 5) = rs.Fields(2).Value
'Third Field
Cells(StartRow, 6) = rs.Fields(3).Value
rs.movenext
StartRow = StartRow + 1
Loop
rs.Close
Set rs = Nothing
con.Close
Set con = Nothing
End Sub
I receive the following error message: 'Run-time error'
Microsoft ODBC Driver Manager Data Source name not found and no default
driver specified.
This line is yellow:
con.Open
I feel the error is here:
con.ConnectionString = "DBO=C:\Temp\MyAccess.accdb:" & _
"Driver = (Microsoft Access Dirver (*.accdb));"
I am using Office 2007.
following VBA into Excel:
Sub Rectangle1_Click()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
'Drive code for Access
con.ConnectionString = "CBO=C:\Temp\MyAccess.accdb:" & _
"Driver = (Microsoft Access Dirver (*.accdb));"
'Open DB Connection
con.Open
Set rs.activeconnection = con
rs.Open "Select * from SharePrices"
StartRow = 3
Do Until rf.EOF
'First Field
Cells(StartRow, 4) = rs.Fields(1).Value
'Second Field
Cells(StartRow, 5) = rs.Fields(2).Value
'Third Field
Cells(StartRow, 6) = rs.Fields(3).Value
rs.movenext
StartRow = StartRow + 1
Loop
rs.Close
Set rs = Nothing
con.Close
Set con = Nothing
End Sub
I receive the following error message: 'Run-time error'
Microsoft ODBC Driver Manager Data Source name not found and no default
driver specified.
This line is yellow:
con.Open
I feel the error is here:
con.ConnectionString = "DBO=C:\Temp\MyAccess.accdb:" & _
"Driver = (Microsoft Access Dirver (*.accdb));"
I am using Office 2007.