+ Reply to Thread
Results 1 to 10 of 10

ADODB recordset on excel table return null value when it shouldn't

  1. #1
    Registered User
    Join Date
    04-08-2016
    Location
    Ciudad Real, Spain
    MS-Off Ver
    Ms Office Professional Plus 2010 v14.0.7166.5000 64bits
    Posts
    5

    ADODB recordset on excel table return null value when it shouldn't

    Hi!

    I have an excel workbook full with VBA code to get several things done. I need frequent querys to data tables hosted inside the workbook, no RDBMS system in use this time.

    However, I've found very convenient to solve this querys using ADODB recordsets. I implement this kind of recordsets with this Function in one of my utility modules

    Please Login or Register  to view this content.
    And I use this function in code like this:

    Please Login or Register  to view this content.

    This have been working like a charm for months now, but a couple of days ago I suddenly found a problem. There are some recordsets that return null values for some fields even when the actual value of the cell in the table is not null.

    I've made several tests and google for similar issues but found nothing.

    Have anyone a clue of what the hell is happening here?

    Thank you in advance

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: ADODB recordset on excel table return null value when it shouldn't

    I would suggest that you upload a sample workbook that demonstrates the problem.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    04-08-2016
    Location
    Ciudad Real, Spain
    MS-Off Ver
    Ms Office Professional Plus 2010 v14.0.7166.5000 64bits
    Posts
    5

    Re: ADODB recordset on excel table return null value when it shouldn't

    Hi Trevor, thank you for your attention.

    I've upload a sample wkb, it has just one module with two methods. If you run the one called "test_sqlSelect", it will show you the problem.

    Regards
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-08-2016
    Location
    Ciudad Real, Spain
    MS-Off Ver
    Ms Office Professional Plus 2010 v14.0.7166.5000 64bits
    Posts
    5

    Re: ADODB recordset on excel table return null value when it shouldn't

    Any ideas?

    I'd really appreciate any help

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: ADODB recordset on excel table return null value when it shouldn't

    You have mixed data types (numbers and text) within the same column. That has always been a problem for ADO (since a proper database won't allow you to do that), even if you use IMEX=1. You should convert the numbers to text by prefixing them with an apostrophe and then your code should work.

  6. #6
    Registered User
    Join Date
    04-08-2016
    Location
    Ciudad Real, Spain
    MS-Off Ver
    Ms Office Professional Plus 2010 v14.0.7166.5000 64bits
    Posts
    5

    Re: ADODB recordset on excel table return null value when it shouldn't

    Thank you very much rorya!

    You are absolutely right.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: ADODB recordset on excel table return null value when it shouldn't

    Thank goodness you have a solution. I spent ages stepping through the code trying to understand what was going on.

    I was never going to find the answer! Interesting challenge though

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

    Re: ADODB recordset on excel table return null value when it shouldn't

    I'd also suggest not using ado on an open workbook, there's a known bug which causes memory leaks. If you can live with it and haven't noticed any side effects then it may not be the end of the world, just be aware of it

  9. #9
    Registered User
    Join Date
    04-08-2016
    Location
    Ciudad Real, Spain
    MS-Off Ver
    Ms Office Professional Plus 2010 v14.0.7166.5000 64bits
    Posts
    5

    Re: ADODB recordset on excel table return null value when it shouldn't

    Ok Kyle, I'll keep an eye on it. I haven't notice any side effects so far, as you say.

    Thank you for your warning

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

    Re: ADODB recordset on excel table return null value when it shouldn't

    No problem, if you want a bit more information: https://support.microsoft.com/en-us/kb/319998

+ 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. Change ADODB.Recordset by New
    By Remphan in forum Access Tables & Databases
    Replies: 1
    Last Post: 03-13-2016, 07:51 PM
  2. ADODB Recordset Retrieving Data from a SharePoint Excel File
    By Bradleybww in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-19-2015, 08:59 PM
  3. Replies: 0
    Last Post: 07-19-2012, 11:15 PM
  4. Recordset keeps returning EOF and shouldn't be.
    By BerkshireGuy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2006, 10:33 AM
  5. writing ADODB recordset to excel sheet
    By bhavesh78 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2005, 12:55 PM
  6. VBA excel - problem with having clause in sql with adodb.connection/recordset
    By ukp9999 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2005, 03:50 AM
  7. [SOLVED] Delete ADODB Recordset
    By Jim Thomlinson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2005, 01:06 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