Results 1 to 4 of 4
  1. #1
    mermaidboy is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2015
    Posts
    13

    Problem with DLookup syntax - quick answer to short question!

    Dear all,



    When I try to run an append query,

    the following field: InventoryID: DLookUp("[InventoryID]","InventoryTable","InventoryName=" & [RecipeTable]![RecipeName])

    creates this error message: Syntax error in string in query expression 'InventoryName = Jim's Mayo'.

    Please help.

    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    For starters, a text data type requires delimiters:

    DLookup Usage Samples

    Since your value can contain the apostrophe, you'll have to revise that a little. Untested:

    DLookUp("[InventoryID]","InventoryTable","InventoryName=""" & [RecipeTable]![RecipeName] & """")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mermaidboy is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2015
    Posts
    13
    OK - you are a genius! I just copied & pasted and it worked. Thanks so so much. Nick

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem Nick. Normally in as query you would join the tables instead of using the function. That will be very slow on large tables.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 06-26-2017, 12:19 PM
  2. autosave populates quick reply with my previoues answer
    By crobaseball in forum General Chat
    Replies: 6
    Last Post: 04-05-2014, 03:41 PM
  3. Quick DLookUp question
    By snipe in forum Programming
    Replies: 5
    Last Post: 02-20-2014, 12:16 PM
  4. INSTR(), quick little syntax ?
    By markjkubicki in forum Forms
    Replies: 2
    Last Post: 11-15-2010, 02:46 PM
  5. quick query syntax questions
    By cowboy in forum Access
    Replies: 6
    Last Post: 02-03-2010, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums