+ Reply to Thread
Results 1 to 3 of 3

ADO Run Select Into Queries via Excel VBA - Missing Data via VBA but manual query run np

  1. #1
    Registered User
    Join Date
    08-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    ADO Run Select Into Queries via Excel VBA - Missing Data via VBA but manual query run np

    Hi, I have an Access Database that I am using to store analytics data. I am using Excel as a data presentation layer (basically a data dump with pivot tables). I have some queries that require a string of left outer joins and the performance is fine. The problem I am having is this:

    1. When I run the queries which create temp data tables via "Select into" commands via VBA, the results yield a table of results data but with a portion of the data missing. It literally makes a table with 6 columns of data but leaves one entire column of data empty.
    2. If I run the make queries "Select into" manually from the access database it has no problems making the tables and populating the data with all results.

    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    Set con = New ADODB.Connection
    With con
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .Open "C:\test.accdb"
    End With

    con.Execute "drop table_names"
    con.Execute "Update_Table_list"

    Anybody run into this problem? Is there something this ADO execute does not like for a "Select Into" queries?

    Thanks,
    Khiem

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: ADO Run Select Into Queries via Excel VBA - Missing Data via VBA but manual query run

    Do you have some functions in the query in Access that are not viable/readable in Excel, ie. the NZ function?
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    08-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: ADO Run Select Into Queries via Excel VBA - Missing Data via VBA but manual query run

    Yes, I was scouring the interweb last night trying to find a solution to this, mostly it just called for me to rewrite it as an excel function and incorporate that into my query call. Seems like a lot of work just to use the ADO instead of just using calling access as an object and making query calls from there. The upshot is that using ADO will help me with some performance issues I am having since the database sits on a network drive and can be extremely quirky.

    Is there anything else I can do to use ADO and still keep these functions in place? These queries were already a giant pain in the rear to write in "Access SQL" as it is. Ex below:

    SWITCH STATEMENT USED:
    FROM (SELECT t.plcode, t.cpty, p.descr AS Parent_Name, Switch(t.isin Like 'CARS*','VEHICLE',t.isin Like 'PLANE*','AIRPLANE',t.isin Like 'BICYLCLE*','BIKE') AS Product, t.startd, t.endd, Sum(t.cash) AS New_Cash FROM (dbo_Trans AS t INNER JOIN dbo_cpty AS c ON t.cpty = c.cpty) INNER JOIN dbo_Parent AS p ON c.parent = p.cpty WHERE (((t.endd)>=DateAdd("d",1,(select * from get_date)) Or (t.endd) Is Null) AND ((t.startd)=Date()) AND ((t.isin) Like 'PLANE%' Or (t.isin) Like 'CARS%' Or (t.isin) Like 'BICYCLE%')) GROUP BY t.plcode, t.cpty, p.descr, t.startd, t.endd, t.isin)

    IIF STATEMENT USED:
    SELECT t.plcode, t.cpty, p.descr AS Parent_Name, Switch(t.isin Like 'CARS*','VEHICLE',t.isin Like 'PLANE*','AIRPLANE',t.isin Like 'BICYLCLE*','BIKE') AS Product, Sum(t.cash) AS Maturity_Cash, (select * from get_date) AS reportdate, sum(iif(startd = reportdate, t.cash)) AS ON_Mat, sum(iif(startd <> reportdate, t.cash)) AS Term_Mat FROM (dbo_Trans AS t INNER JOIN dbo_cpty AS c ON t.cpty = c.cpty) INNER JOIN dbo_Parent AS p ON c.parent = p.cpty WHERE (((t.endd)=date()) AND ((t.isin) Like 'CARS%' or t.isin like 'PLANES%' or t.isin like 'BICYCLE%')) GROUP BY t.plcode, t.cpty, p.descr, t.isin

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel VBA - Run Access Query via ADO yields Missing Column of Data
    By khiem in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-07-2016, 03:10 PM
  2. Replies: 1
    Last Post: 06-14-2012, 08:46 AM
  3. Excel Web query - I can only get max. 9 queries from my macro
    By pfrattali in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2010, 02:36 PM
  4. Importing data from MS-Access: Queries missing
    By mogens in forum Excel General
    Replies: 0
    Last Post: 08-14-2006, 09:20 AM
  5. [SOLVED] Numbers/Text data missing from excel to excel query?
    By RAMAERTE in forum Excel General
    Replies: 0
    Last Post: 05-08-2006, 12:10 PM
  6. Missing Data From Excel Query
    By Suzseb in forum Excel General
    Replies: 0
    Last Post: 04-24-2006, 09:50 AM
  7. Replies: 0
    Last Post: 08-18-2005, 12:05 PM

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