Results 1 to 7 of 7
  1. #1
    Join Date
    May 2005
    Posts
    54

    Red face Unanswered: Silly Where Condition Question

    I probably can't see the forest through the trees, and apologize for asking such an elementary question.

    Can anyone tell me why I keep getting an error (Microsoft Access cannot parse expression....") for the following where condition?

    [PurchaseOrderNumber] Like "*" & [Forms!][Search For Purchase Order]![PurchaseOrderNumber] & "*"



    Thanks for your help

  2. #2
    Join Date
    Oct 2004
    Location
    Oxfordshire, UK
    Posts
    89
    My first thought is it's numeric, but it's more likely to be you can't get quote marks into the string that way. Try CStr([PurchaseOrderNumber]) Like """ & "*" & [Forms!][Search For Purchase Order]![PurchaseOrderNumber] & "*"""

  3. #3
    Join Date
    May 2005
    Posts
    54
    It didn't like that one either (same error)

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    might be the age old double quote problem


    [PurchaseOrderNumber] Like "*" & [Forms!][Search For Purchase Order]![PurchaseOrderNumber] & "*"

    becomes

    [PurchaseOrderNumber] Like " & Chr$(34) & "*" & [Forms!][Search For Purchase Order]![PurchaseOrderNumber] & "*" & Chr$(34)
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    May 2005
    Posts
    54
    Still not working.

    I tried changing it to: [PurchaseOrderNumber]=[Forms]![Search For Purchase Order]![PurchaseOrderNumber]

    following the format that Microsoft Access gives as an example, but it doesn't return anything....the form is blank.


    Microsoft Access example
    [fieldname] = Forms![formname]![controlname on other form]

  6. #6
    Join Date
    Oct 2004
    Location
    Oxfordshire, UK
    Posts
    89
    Indeedy....Hangs head in shame :-)

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    is purchaseorder number a number or a string
    that could be your issue, if consider explciitly changing the text box data type to a number
    if its a string then you need tell the SQL that its a string by encasing it in double quote marks
    could be
    [PurchaseOrderNumber]=chr$(34) & [Forms]![Search For Purchase Order]![PurchaseOrderNumber] & chr$(34)

    ..the chr$(34) adds a double quote mark

    personally I dont use this style of code in writing queries, I always use a parameter pulled directly from a form and write the SQL as required so cant be sure what your problem is.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •