+ Reply to Thread
Results 1 to 8 of 8

VBA SQL Query not returning All Results

  1. #1
    Registered User
    Join Date
    03-12-2010
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    21

    VBA SQL Query not returning All Results

    When running query SELECT * FROM [Input$A1:G57] Where [info2] = "Aasvoelnes_U9A_0" OR [info2] = "Affenberg_U9A_1" ORDER BY [info2] in attached xlsb book, it is only returning the first 14 results although it is suppose to be 57 results.

    Here is the code:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA SQL Query not returning All Results

    There are only 14 records that have those values in the info2 field. The code is working correctly, wha are you actually trying to do?

    P.S Running ADO on an open workbook isn't a good idea, it causes memory leaks

  3. #3
    Registered User
    Join Date
    03-12-2010
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    21

    Re: VBA SQL Query not returning All Results

    My apologies , yes I was focused on the Name Field & not the Info Field

    So one should rather use oledb connection?

    Thank you Kyle123

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA SQL Query not returning All Results

    No, you should use advanced filter

  5. #5
    Registered User
    Join Date
    03-12-2010
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    21

    Re: VBA SQL Query not returning All Results

    The idea is to use less code & using SQL suppose to be faster with minimum code, not gonna do too complex queries, still prefer Excel as I'm comfortable in it compared to using SQL server, etc.

    (I'm using input data with up to a million rows)
    Last edited by ocnuybear; 09-23-2021 at 07:22 AM.

  6. #6
    Registered User
    Join Date
    03-12-2010
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    21

    Re: VBA SQL Query not returning All Results

    Just saw your other post on https://www.excelforum.com/excel-pro...db-12-0-a.html

    Maybe I can try Power Query in Excel although it seems it uses different syntax than normal SQL.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA SQL Query not returning All Results

    Advanced Filter is Excel - why can't you use that? I'd be surprised if ADO is actually faster

  8. #8
    Registered User
    Join Date
    03-12-2010
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    21

    Re: VBA SQL Query not returning All Results

    Hi Kyle123, I have started playing with Advanced Filters & it is way better then the normal filter and learned to copy & paste only specific columns very much like SQL, so I will be using them from now one, thank you I learned something very helpful today

+ 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. [SOLVED] Query returning no results when data is there (Problem is at c = ...)
    By cbogner in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 2
    Last Post: 07-05-2017, 04:31 PM
  2. Replies: 1
    Last Post: 09-08-2015, 08:12 PM
  3. Sort Query Results to remove duplicate entries and put results on one line.
    By Panther70 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-01-2015, 03:03 PM
  4. Microsoft Query Returning Blank Cells/Results
    By skull132 in forum Excel General
    Replies: 2
    Last Post: 07-11-2014, 04:26 AM
  5. [SOLVED] Access unmatched query returning Blank Results
    By jonboy6257 in forum Access Tables & Databases
    Replies: 4
    Last Post: 12-04-2013, 10:46 AM
  6. Query results on subform updated but old results stilled displayed
    By menmine5 in forum Access Tables & Databases
    Replies: 1
    Last Post: 09-29-2013, 02:37 AM
  7. [SOLVED] SQL Query not returning correct results
    By Stephen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2006, 08:25 AM

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