Missing operator in query, DLookUp()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dago87
    New Member
    • May 2016
    • 2

    Missing operator in query, DLookUp()

    Hello.
    I have following function in my query
    Code:
    DLookUp("name","Q[-]shortages","Q[-]shortages.ItemNumber='" & [PartNumber] & "'") AS Facility
    I'm getting an error: Syntax error (missing operator) in query expression: 'Q[-]shortages.ItemN umber=1010'"

    Q-shortages is another query, it's not table.

    I really don't know what may be wrong.
    Thank you for any help
    Last edited by NeoPa; May 30 '16, 04:43 PM. Reason: Added mandatory [CODE] tags. Without them the question is very hard to read properly.
  • PhilOfWalton
    Recognized Expert Top Contributor
    • Mar 2016
    • 1430

    #2
    If PartNumber is numeric, you don't need the extra single quotes, if it is text,you do need them.

    I would be very very very suspicious of how Access would handle those square brackets in Q[-]shortages. Change the name of your query simply to QShortages. Square brackets are normally used to indicate that 2 words are to be treated as one, so you can't use Last Name, but you can use [Last Name]

    Sorry to go on, but "name" is a reserved word, and should not be used as the name of a field in any table. Don't know what you are after but FacilityName is perfectly acceptable.

    Another reserved word that frequently causes trouble is "Date"

    Code:
    DLookUp("FacilityName","QShortages","ItemNumber=" & [PartNumber]) AS Facility

    Comment

    • dago87
      New Member
      • May 2016
      • 2

      #3
      Thank you for fast reply, but sadly none of your suggestion have helped.
      PartNumber is text field.
      There has to be error somewhere in those double/single quotes.
      Code:
      [B]'[/B]Q[-]shortages.ItemNumber=1010[B]'[/B]"

      Comment

      • PhilOfWalton
        Recognized Expert Top Contributor
        • Mar 2016
        • 1430

        #4
        You haven't got rid of those square brackets

        Phil

        Comment

        • PhilOfWalton
          Recognized Expert Top Contributor
          • Mar 2016
          • 1430

          #5
          Try
          Code:
          DLookup ("Name", "QShortages", "ItemNumber = " & Chr$(34) & PartNumber & Chr$(34))
          Chr$(34) is always much clearer than a string of single & double quotes

          Phil

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32662

            #6
            @Dago.
            Your code and the error message simply don't match. One of them must be wrong.

            Please check the details of your question before posting.

            Please update the question with the correction(s) required.

            Comment

            Working...