+ Reply to Thread
Results 1 to 9 of 9

Excel 2007 : Problem using "begins with" parameter in Excel Query

  1. #1
    Registered User
    Join Date
    02-19-2010
    Location
    Ventura, California
    MS-Off Ver
    Excel 2007
    Posts
    4

    Problem using "begins with" parameter in Excel Query

    Hi,

    I'm trying to use a parameter in Excel's Microsoft Query that looks as follows:
    (dwt_PCKSOD.PART_ID Like '[]%') where [] is a user input text field. It works fine when the statement is an "equal" but returns "Syntax Error" when I use "begins with" or "like".

    Any solutions to my problem would be greatly appreciated.

    Thanks,

    John
    Last edited by vtalin; 01-16-2012 at 03:38 PM. Reason: Add Excel reference

  2. #2
    Registered User
    Join Date
    02-19-2010
    Location
    Ventura, California
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Problem using "begins with" parameter in Query

    Bump no response

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Problem using "begins with" parameter in Excel Query

    John, is make no sense.

    Would you like to upload a sample worksheet?
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Registered User
    Join Date
    02-19-2010
    Location
    Ventura, California
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Problem using "begins with" parameter in Excel Query

    Fotis,

    Please see worksheet atached. It won't work without a link to our database though. This is the current Query definition:

    SELECT SOFOD.SO_ID, SOFOD.SO_LINE_NO, dwt_PCKSOD.PART_ID, dwt_PCKSOH.PICK_DATE, dwt_PCKSOD.PICK_DATE, dwt_PCKSOH.OPERATOR_ID, dwt_PCKSOD.QTY, SOFOD.REV_ORDER_QTY, SOFOD.SHIPPED_QTY, SOFOD.BALANCE_DUE, SOFOD.SO_LINE_STATUS, dwt_PCKSOD.BATCH_NUMBER, SOFOD.STORES_CODE
    FROM ESIDB.dbo.dwt_PCKSOD dwt_PCKSOD, ESIDB.dbo.dwt_PCKSOH dwt_PCKSOH, ESIDB.dbo.SOFOD SOFOD
    WHERE dwt_PCKSOD.SO_LINE_NO = SOFOD.SO_LINE_NO AND dwt_PCKSOD.BATCH_NUMBER = dwt_PCKSOH.BATCH_NUMBER AND dwt_PCKSOH.SO_ID = SOFOD.SO_ID AND ((dwt_PCKSOD.BOX_TYPE='a') AND (dwt_PCKSOD.PART_ID Like 'DSMA%') AND (SOFOD.SO_LINE_STATUS='O'))
    ORDER BY dwt_PCKSOD.PART_ID

    If I change it as follows, I get a Syntax Error message :

    SELECT SOFOD.SO_ID, SOFOD.SO_LINE_NO, dwt_PCKSOD.PART_ID, dwt_PCKSOH.PICK_DATE, dwt_PCKSOD.PICK_DATE, dwt_PCKSOH.OPERATOR_ID, dwt_PCKSOD.QTY, SOFOD.REV_ORDER_QTY, SOFOD.SHIPPED_QTY, SOFOD.BALANCE_DUE, SOFOD.SO_LINE_STATUS, dwt_PCKSOD.BATCH_NUMBER, SOFOD.STORES_CODE
    FROM ESIDB.dbo.dwt_PCKSOD dwt_PCKSOD, ESIDB.dbo.dwt_PCKSOH dwt_PCKSOH, ESIDB.dbo.SOFOD SOFOD
    WHERE dwt_PCKSOD.SO_LINE_NO = SOFOD.SO_LINE_NO AND dwt_PCKSOD.BATCH_NUMBER = dwt_PCKSOH.BATCH_NUMBER AND dwt_PCKSOH.SO_ID = SOFOD.SO_ID AND ((dwt_PCKSOD.BOX_TYPE='a') AND (dwt_PCKSOD.PART_ID Like '[]%') AND (SOFOD.SO_LINE_STATUS='O'))
    ORDER BY dwt_PCKSOD.PART_ID
    Attached Files Attached Files

  5. #5
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Problem using "begins with" parameter in Excel Query

    Perhaps you can use something like
    Like [] & '%'
    instead?
    Good luck.

  6. #6
    Registered User
    Join Date
    02-19-2010
    Location
    Ventura, California
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Problem using "begins with" parameter in Excel Query

    I tried the Like [] & '%' and it returned the error message attached

    Thanks,


    John
    Attached Files Attached Files

  7. #7
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Problem using "begins with" parameter in Excel Query

    What if you replace the & with + instead?

  8. #8
    Registered User
    Join Date
    04-22-2012
    Location
    Colorado
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Problem using "begins with" parameter in Excel Query

    Did you find a solution to this? This might help me solve my current problem, where I really need some "IF" logic around the parameter...for example, I need to say, "If the user doesn't input anything, don't query - if they input something, query on that as the criteria." Since all user values start with the same character, in my case, I could just use the logic you were after.

  9. #9
    Registered User
    Join Date
    10-05-2012
    Location
    Peterborough, England
    MS-Off Ver
    Excel 2007
    Posts
    0

    Re: Excel 2007 : Problem using "begins with" parameter in Excel Query

    + instead of & worked for me, thanks

  10. #10
    Registered User
    Join Date
    06-03-2016
    Location
    UK
    MS-Off Ver
    2010
    Posts
    5
    Hello, I appreciate this thread is 4years old now, however I need to know what SO_LINE_NO means?!

    Is it how many lines a particular sales order is? I'm contextualising someones old Microsoft query and that's the only column I don't understand?

    I'd be very greatful if anyone can tell me what it stands for on an excel query database chart and what its used for?

    Thank you

+ 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