+ Reply to Thread
Results 1 to 2 of 2

ADO recordset source: trying to join a table to a Select statement

  1. #1
    Registered User
    Join Date
    09-27-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007, 2010, 2013
    Posts
    11

    Question ADO recordset source: trying to join a table to a Select statement

    Hi, I am connecting to an Excel workbook via ADO using provider Microsoft.ACE.OLEDB.12.0. The workbook has two sheets with similar fields, but the second sheet has an additional field, "Price". On the first sheet rows have a unique identifier column named "JobNo", but on the second sheet the rows are not uniquely identified by this field, in other words more than 1 row can have the same JobNo. I want to create a summary query on the second sheet that will group data by the "JobNo" field, and then join this query to the first sheet. Something like this:

    <code>
    strSQL = "SELECT [Sheet1$].[JobNo], tbl.Sum1 FROM [Sheet1$] LEFT JOIN (SELECT [Sheet2$].[JobNo], SUM([Sheet2].[Price]) FROM [Sheet2$] GROUP BY [Sheet2$].[JobNo]) tbl ON [Sheet1$].[JobNo] = tbl.JobNo"
    rs.open strSQL, cn
    </code>

    When I step through the code this line produces a run-time error: "No value given for one or more required parameters.". Does anybody have experience of joining a Sheet with a Select statement in a query?

    Sorry I don't know what the tags are for code.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: ADO recordset source: trying to join a table to a Select statement

    [Sheet2].[Price] should be [Sheet2$].[Price]
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1