+ Reply to Thread
Results 1 to 6 of 6

Excel VBA database query fails using ADO.

  1. #1
    Registered User
    Join Date
    08-01-2010
    Location
    American in Rovereto, Italy
    MS-Off Ver
    Excel 2010 home & Excel 2010 work
    Posts
    46

    Excel VBA database query fails using ADO.

    Hello,

    I'm having a problem with an Excel VBA lookup query using ADO.

    Hopefully I've missed something obvious to someone with more database experience.
    I built this ADO class myself, but I have only a little database experience gained by trail and error.

    My MS Access .accdb supplier database contains several firms which begin with the word steel.
    When I query Steel% I get nothing back, but if I query Steel%Stock% it works perfectly.

    A user form generates the filter from user input boxes and then submits the query to the ADO class.

    I have used debug.print to watch the sFilter being generated and the result is Steel%


    The query is done by an ADO class which uses SQL Like
    this is the code used to call the class method
    Please Login or Register  to view this content.
    This is the code in the class method

    Please Login or Register  to view this content.
    Gordon in Rovereto, Italy

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

    Re: Excel VBA database query fails using ADO.

    are you certain there is nothing (eg leading space) before the 'Steel' in the name?
    Josie

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

  3. #3
    Registered User
    Join Date
    08-01-2010
    Location
    American in Rovereto, Italy
    MS-Off Ver
    Excel 2010 home & Excel 2010 work
    Posts
    46

    Re: Excel VBA database query fails using ADO.

    I double checked the sFilter result to be sure. There are no leading characters. I even tried using trim(sFilter) to be sure. The result is the same.

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

    Re: Excel VBA database query fails using ADO.

    I meant in the data, not in the filter criteria

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

    Re: Excel VBA database query fails using ADO.

    does it work if you use %Steel% instead for instance?

  6. #6
    Registered User
    Join Date
    08-01-2010
    Location
    American in Rovereto, Italy
    MS-Off Ver
    Excel 2010 home & Excel 2010 work
    Posts
    46

    Re: Excel VBA database query fails using ADO.

    I found the problem. I had a logic error using ubound to get a rowcount. The problem is solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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