Hi, I am working through Microsoft Knowledge Base Article 213772 "How to Use System, User, and File Data Sources"
It describes how to use an Excel VBA Macro to link up (via ODBC) to the MS Access sample database Northwind.mdb
My VBA code is as follows:
Sub Get_Data()
'Define SQL query string to get the CategoryName field from the Category table.
sqlstring = "SELECT CategoryName FROM Categories"
'Define connection string and reference File DSN.
connstring = "ODBC;DSN=northwind"
'Create QueryTable in worksheet beginning with cell C1.
With ActivSheet.QueryTables.Add
(Connectio
n:=connstr
ing, Destination:=Range("C1"), sql:=sqlstring)
.Refresh
End With
End Sub
If I step through this sub I get "Runtime error 424 object required" on the line with the Add method.
I have configured the ODBC so that on the System DSN tab of the ODBC Data Source Administrator it reads: northwind Microsoft Access Driver (*.mdb)
Can anyone tell why this doesn't work?
Thanks,
DevonportA1
Start Free Trial