+ Reply to Thread
Results 1 to 4 of 4

Microsoft Query Unable to Pass String or Date Parameters Back Into Worksheet

  1. #1
    Registered User
    Join Date
    04-12-2016
    Location
    Seattle, WA
    MS-Off Ver
    Office 2013
    Posts
    2

    Microsoft Query Unable to Pass String or Date Parameters Back Into Worksheet

    Hi All,

    I'm running into an issue using Microsoft Query that is not allowing me to pass strings or dates as parameters. However, passing integers as parameters works fine. Say I start with the following dataset that I have retrieved from database using the MS Query:


    TIME ERROR_YN RECEIVED_TIME SEQUENCE_NO
    4/1/2016 0:15 N 4/1/2016 0:15 270316028
    4/1/2016 0:25 Y 4/1/2016 0:25 270313029
    4/1/2016 0:35 N 4/1/2016 0:35 270316030
    4/1/2016 0:40 Y 4/1/2016 0:40 270313031
    4/1/2016 0:40 N 4/1/2016 0:40 270316032
    4/1/2016 0:45 N 4/1/2016 0:45 270316033
    4/1/2016 1:05 N 4/1/2016 1:05 270313034
    4/1/2016 1:10 N 4/1/2016 1:10 270316035
    4/1/2016 1:25 N 4/1/2016 1:25 270316036
    ...
    ...
    ...

    When I open up MS query and apply criteria I want to filter on (in this case for the ERROR_YN field), I can manually set the error message content to be either 'Y' or 'N' and I will have no problem both preview the data in MS Query and returning the data to the table in the worksheet.

    However, if I set that ERROR_YN to an input parameter (filter criteria for ERROR_YN now set to [ERROR]), I am prompted for input and am able to preview the results in MS Query but it will NOT return data upon refreshing it in the worksheet itself. I have tried both direct input from the prompt as well as passing the parameter from another cell in the worksheet but it is never able to pull anything back even though I know both 'Y' and 'N' values exist in the data set. I am, however, able to pass integers through as parameters just fine.

    Has anyone ever come across this issue? I searched the forum and did a quick google but I was unable to find any issues directly related to what I'm experiencing.

    Thanks!

    Andrew

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

    Re: Microsoft Query Unable to Pass String or Date Parameters Back Into Worksheet

    I'll ask the obvious (and stupid) questions. Are the Y and N in the database really Y and N or do they have hidden spaces attached to them? Are they the same case as the parameters you are trying to pass? Are they really ASCII 78 and 89 respectively? Are you passing the parameter "as is" - that is without the quotes around them?

    What happens if you hard coded a 'Y' or 'N' into the SQL?

    I'm assuming that the query can be displayed graphically.

    It's so nice to see another person who even knows what MS-Query is.
    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.

  3. #3
    Registered User
    Join Date
    04-12-2016
    Location
    Seattle, WA
    MS-Off Ver
    Office 2013
    Posts
    2

    Re: Microsoft Query Unable to Pass String or Date Parameters Back Into Worksheet

    Hi dflak,

    Thanks for the response! Answers to your questions below:

    Q: Are the Y and N in the database really Y and N or do they have hidden spaces attached to them?
    A: They are really Y and N. There are no extra spaces before or after the character.

    Q: Are they the same case as the parameters you are trying to pass?
    A: Yes. They are all upper case.

    Q: Are they really ASCII 78 and 89 respectively?
    A: I double checked this and they really are ASCII 78 and 89.

    Q: Are you passing the parameter "as is" - that is without the quotes around them?
    A: I've been passing them as is. I also tried adding quotes around them just in case but that didn't work either.

    Q: What happens if you hard coded a 'Y' or 'N' into the SQL?
    A: When I hard code it into the query, I'm able to pull data back.

    The strangest thing is that this used to work just fine so I'm wondering if it's possible that there is some sort of clash between a recent Excel update and the ODBC driver I'm using to connect to the data source. The reason I say that is because I set up a dummy Access database and I was able to use that as my data source in Excel just fine with string parameters. I've also tried this on a few of my coworkers machines as well and I'm getting the same outcome. I'll keep digging.

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

    Re: Microsoft Query Unable to Pass String or Date Parameters Back Into Worksheet

    The last answer is most revealing. It pulls back the correct data. So this means that there is something amiss with passing the parameter to the SQL. The rest of the engine is responding properly.

    What happens if you rebuild the query in another spreadsheet from scratch? Compare the connection strings just for grins. You could try reloading the drivers, but we've gone from Excel 2003 to Excel 2007 to Excel 2013 over the course of several years and we've not had this kind of issue. We're talking to an Oracle database.

+ 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. Pass parameters in query to Access DB
    By ishq786 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2015, 11:20 PM
  2. Microsoft Query not returning same data back to Excel
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-06-2012, 02:51 PM
  3. Excel 2007 - Pass Parameters from Excel SQL Query
    By Jeffs23 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-15-2009, 11:37 AM
  4. Microsoft Query seperates parameters in pivot table
    By eldoradotower in forum Excel General
    Replies: 1
    Last Post: 09-16-2008, 10:10 PM
  5. Microsoft Query-Chg parameters using VBA
    By yzer19 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-29-2008, 11:08 PM
  6. [SOLVED] Microsoft query won't allow parameters
    By kmoyer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-20-2006, 02:45 PM
  7. [SOLVED] Is there a way to pass parameters to a web query in excel
    By daytonsupply in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2005, 01:06 PM

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