Advertisement

05.21.2004 at 08:23AM PDT, ID: 20997775
[x]
Attachment Details

Excel link with Access database via ODBC and VBA macro will not work.

Asked by DevonportA1 in Microsoft Excel Spreadsheet Software

Tags: excel, vba, access, odbc, link

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(Connection:=connstring, 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
[+][-]05.21.2004 at 01:18PM PDT, ID: 11129948

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Excel Spreadsheet Software
Tags: excel, vba, access, odbc, link
Sign Up Now!
Solution Provided By: sebastienm
Participating Experts: 5
Solution Grade: B
 
 
[+][-]05.22.2004 at 12:30AM PDT, ID: 11132228

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.24.2004 at 08:06AM PDT, ID: 11143700

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.24.2004 at 08:47AM PDT, ID: 11144061

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.10.2004 at 04:03AM PDT, ID: 11277952

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.11.2005 at 12:23PM PDT, ID: 14415327

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32