+ Reply to Thread
Results 1 to 2 of 2

MS Query wildcard with parameter NOT working, help please

  1. #1
    Registered User
    Join Date
    06-13-2016
    Location
    Middlebury, VT
    MS-Off Ver
    Office 365
    Posts
    3

    MS Query wildcard with parameter NOT working, help please

    I have a SQL ODBC connection using MS Query in Excel. I use a parameter to define a sql command in MS Query but the wildcard is just not working.
    The command in MS Query is (TABLE.COLUMN Like '%'+?+'%'). ? refers to the parameter.
    I put C177 in the parameter and it returns info but not ALL the info. I have fields with C175C176C177 which the query doesn't return; it will only return fields that have ONLY C177 in them. The SQL query on the SQL server works fine but when I use the exact same language using the parameter wildcard in MS query it breaks it. If I use an exact choice in MS query like C177 it returns properly, it's only when I use the parameter "?" for some reason.

    Help please, this is driving me nuts!

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,910

    Re: MS Query wildcard with parameter NOT working, help please

    Think about what you are asking the Like statement to do.

    If you specified Like 'C+?+177', the query should pick up everything starting with C and ending in 177. Or maybe you want '%C177' to catch everything ending in 177. How does the pattern know where to place the C and the 177? It doesn't

    What you will have to do is prompt for the parameter (for example Like [Part Number], and enter in something like %C177% as the parameter. Maybe you enter C177 in one cell (for example F1) and then use a formula like ="%" & F1 & "%" to calculate the parameter string. The pattern has to be entered as the parameter and the data will match to it.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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. MS Query - Wildcard 'Like' with a parameter
    By Smithsc in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 05-17-2018, 10:26 AM
  2. Using WildCard in MS Query Parameter - 32 bit vs 64 bit
    By dhorner65 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2015, 04:39 PM
  3. Replies: 2
    Last Post: 10-06-2014, 08:15 AM
  4. Replies: 0
    Last Post: 10-06-2014, 07:35 AM
  5. LIKE not working with wildcard in MS Query
    By RollerRagerMD in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-03-2013, 10:02 AM
  6. Parameter wildcard % query using ODCB to SQL database
    By SA1Martin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2012, 11:02 PM
  7. Passing wildcard character % in parameter for ODBC Query to SQL Database?
    By ilikeexcel1 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-06-2012, 09:53 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